![]() |
VOOZH | about |
Lodash _.chunk() function is used to break the array into small chunks. Each chunk is an array of sizes as given.
_.chunk(array, size);It returns the array of chunks that is also an array.
Example 1: In this example, we are breaking the array by passing size '1' into the _.chunk() method.
Output:
Example 2: In this example, we are breaking the array by passing size '3' into the _.chunk() method. The size of chunk can be varied and array of different data type can be used with chunk function.
Output:
Example 3: In this example, we are breaking the 2d array by passing size '2' into the _.chunk() method. Using array of array with chunk.
Output:
Example 4: In this example, we are breaking the array of object by passing size '1' into the _.chunk() method.
Output :