const arr = [10, 20, 30, 40, 50];
const result = _.initial(arr);
// => [10,20,30,40]
In the code snippet, we have an array arr and we want to get all elements of it except the last one. We are doing that using the .initial() method of lodash.
_.initial(Array)
Parameters description
Array: [Required] The array whose elements you want to get except the last one.
0 Comments