mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
381 B
23 lines
381 B
10 years ago
|
/**
|
||
|
* Gets the first element of `array`.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
9 years ago
|
* @alias first
|
||
10 years ago
|
* @category Array
|
||
|
* @param {Array} array The array to query.
|
||
|
* @returns {*} Returns the first element of `array`.
|
||
|
* @example
|
||
|
*
|
||
9 years ago
|
* _.head([1, 2, 3]);
|
||
10 years ago
|
* // => 1
|
||
|
*
|
||
9 years ago
|
* _.head([]);
|
||
10 years ago
|
* // => undefined
|
||
|
*/
|
||
9 years ago
|
function head(array) {
|
||
10 years ago
|
return array ? array[0] : undefined;
|
||
|
}
|
||
|
|
||
9 years ago
|
module.exports = head;
|