Methods
(static) chunk(array, sizeopt) → {Array}
- Source:
- Since:
- 0.1.0
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.
Example
_.chunk(['a', 'b', 'c', 'd'], 2)
// => [['a', 'b'], ['c', 'd']]
_.chunk(['a', 'b', 'c', 'd'], 3)
// => [['a', 'b', 'c'], ['d']]
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array |
Array | The array to process. | ||
size |
number |
<optional> |
1
|
The length of each chunk |
Returns:
Returns the new array of chunks.
- Type
- Array
(static) compact(array) → {Array}
- Source:
- Since:
- 0.1.0
Creates an array with all falsey values removed. The values `false`, `null`,
`0`, `""`, `undefined`, and `NaN` are falsey.
Example
_.compact([0, 1, false, 2, '', 3])
// => [1, 2, 3]
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | The array to compact. |
Returns:
Returns the new array of filtered values.
- Type
- Array
(static) concat(array, …valuesopt)
- Source:
- Since:
- 0.1.0
Creates a new array concatenating array with any additional arrays and/or values.
Example
_.concat([1], 2, [3], [[4]]);
// => [1, 2, [3], [[4]]
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
array |
Array | The array to concatenate. | |
values |
* |
<optional> <repeatable> |
The values to concatenate. |