_.chunk(array, [size=1])
Creates an array of elements split into groups the length of size
. If array
can't be split evenly, the final chunk will be the remaining elements.
Since
3.0.0
Arguments
array
(Array): The array to process.[size=1]
(number): The length of each chunk
Returns
(Array): Returns the new array of chunks.
Example
_.chunk(['a', 'b', 'c', 'd'], 2);// => [['a', 'b'], ['c', 'd']]_.chunk(['a', 'b', 'c', 'd'], 3);// => [['a', 'b', 'c'], ['d']]
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .