@newdash/newdash
Version:
javascript/typescript utility library
28 lines (27 loc) • 572 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.tail = void 0;
/**
* Gets all but the first element of `array`.
*
* @since 5.13.0
* @category Array
* @param {Array} array The array to query.
* @returns {Array} Returns the slice of `array`.
* @example
*
* ```js
* tail([1, 2, 3])
* // => [2, 3]
* ```
*/
function tail(array) {
const length = array == null ? 0 : array.length;
if (!length) {
return [];
}
const [, ...result] = array;
return result;
}
exports.tail = tail;
exports.default = tail;