Returns all the elements of an array except the last one.
Array.prototype.slice()
to return all but the last element of the array.const initial = arr => arr.slice(0, -1);
initial([1, 2, 3]); // [1, 2]
JavaScript, Array
Executes a provided function once for each array element, starting from the array's last element.
JavaScript, Array
Filters out the elements of an array that have one of the specified values.
JavaScript, Array
Returns all elements in an array except for the first one.