![]() |
VOOZH | about |
Lodash _.slice() function is used to take a slice of the array from the starting index to the end index here end index is exclusive and the start index is inclusive.
_.slice(array, startIndex, endIndex);Example 1: In this example, we are slicing an array and the given index size is in the range of the array size.
Output:
👁 Image
Example 2: In this example, we are slicing an array and the given end index is not in range of the size of the array.
Output:
👁 Image
Example 3: In this example, we are slicing the empty array.
Output:
👁 ImageExamples 4: In this example, we are slicing an array where start and end index are not given.
Output:
👁 Image