Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (17 sloc)
369 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets the last element of `array`. | |
* | |
* @since 0.1.0 | |
* @category Array | |
* @param {Array} array The array to query. | |
* @returns {*} Returns the last element of `array`. | |
* @example | |
* | |
* last([1, 2, 3]) | |
* // => 3 | |
*/ | |
function last(array) { | |
const length = array == null ? 0 : array.length | |
return length ? array[length - 1] : undefined | |
} | |
export default last |