Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
/**
2
* Gets the last element of `array`.
3
*
4
* @static
5
* @memberOf _
6
* @category Array
7
* @param {Array} array The array to query.
8
* @returns {*} Returns the last element of `array`.
9
* @example
10
*
11
* _.last([1, 2, 3]);
12
* // => 3
13
*/
14
function last(array) {
15
var length = array ? array.length : 0;
16
return length ? array[length - 1] : undefined;
17
}
18
19
module.exports = last;
20
21