UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

30 lines (29 loc) 547 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.head = void 0; /** * Gets the first element of `array`. * * @since 5.0.0 * @alias first * @category Array * @param array The array to query. * @returns Returns the first element of `array`. * @see last * @example * * ```js * head([1, 2, 3]) * // => 1 * * head([]) * // => undefined * ``` */ function head(array) { return (array != null && array.length) ? array[0] : undefined; } exports.head = head; exports.default = head;