Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
/**
* Return the first element of the given array.
*
* @param {*} array - anything
* @returns {*} first element of the array, or undefined
*
* @alias module:array-utils.head
* @function
*
* @example
* let element = head([1, 2]) // return 1
*/
export const head = (array) => {
if (!Array.isArray(array) || array.length === 0) {
return undefined
}
return array[0]
}
db621ec01This file is pinned to the selected release. Download the original to open it in your design tool.