Today I Learned
Implemented underscore libray’s last function
1
2
3
4
5// Like first, but for the last elements. If n is undefined, return just the
// last element.
_.last = function(array, n) {
return n === undefined ? array[array.length-1] : n > array.length ? array : array.slice(array.length-n, array.length);
};Studied about JavaScript global variable and let, const keyword variables.