![]() |
VOOZH | about |
Lodash _.initial() function is used to get all elements of the array in the range 0 to n-2. Thereby getting all elements except the (n-1)th element.
Lodash.initial(arrayObject);Example 1: In this example, When an array of objects is given we are getting all the elements of that array but not the last one because of the use of the lodash _.initial() function.
Output:
👁 Image
Example 2: In this example, we are getting all the elements of that array but not the last one because of the use of the lodash _.initial() function.
Output:
👁 ImageExample 3: In this example, we are getting empty array beacuse the original array has only one element.