1-liners
Version:
Useful oneliners and shorthand functions
26 lines (23 loc) • 433 B
JavaScript
/**
* @module 1-liners/butLast
*
* @description
*
* Return a copy of `array`, without the last item.
*
* @example
*
* import butLast from '1-liners/butLast';
*
* const array = [1, 2, 3];
*
* butLast(array); // => [1, 2]
* array; // => [1, 2, 3]
*
*/
;
exports.__esModule = true;
exports["default"] = function (array) {
return array.slice(0, -1);
};
module.exports = exports["default"];