1-liners
Version:
Useful oneliners and shorthand functions
19 lines (18 loc) • 327 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]
*
*/
export default (array) => array.slice(0, -1);