PageRenderTime 23ms CodeModel.GetById 20ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/lodash/head.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 23 lines | 4 code | 1 blank | 18 comment | 1 complexity | 457bb3cd8109f31fbc3e1ce989c0dea9 MD5 | raw file
 1/**
 2 * Gets the first element of `array`.
 3 *
 4 * @static
 5 * @memberOf _
 6 * @since 0.1.0
 7 * @alias first
 8 * @category Array
 9 * @param {Array} array The array to query.
10 * @returns {*} Returns the first element of `array`.
11 * @example
12 *
13 * _.head([1, 2, 3]);
14 * // => 1
15 *
16 * _.head([]);
17 * // => undefined
18 */
19function head(array) {
20  return (array && array.length) ? array[0] : undefined;
21}
22
23module.exports = head;