UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

24 lines (23 loc) 503 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.last = void 0; /** * Gets the last element of `array`. * * @since 5.6.0 * @category Array * @param array The array to query. * @returns Returns the last element of `array`. * @example * * ```js * last([1, 2, 3]) * // => 3 * ``` */ function last(array) { const length = array == null ? 0 : array.length; return length ? array[length - 1] : undefined; } exports.last = last; exports.default = last;