156 B
156 B
Last of list
Use arr.slice(-1)[0] to get the last element of the given array.
const last = arr => arr.slice(-1)[0];
// last([1,2,3]) -> 3
Use arr.slice(-1)[0] to get the last element of the given array.
const last = arr => arr.slice(-1)[0];
// last([1,2,3]) -> 3