4.17.11
3.10.1
2.4.2
1.3.1
_.flatMap(collection, [iteratee=_.identity])
Creates a flattened array of values by running each element in collection
thru iteratee
and flattening the mapped results. The iteratee is invoked
with three arguments: (value, index|key, collection).
Since
4.0.0
Arguments
argument
collection
[iteratee=_.identity]
type
(Array|Object)
Function
description
The collection to iterate over.
The function invoked per iteration.
Returns
(array)
Example
function duplicate(n) {
return [n, n];
}
_.flatMap([1, 2], duplicate);
// => [1, 1, 2, 2]
function duplicate(n) {
return [n, n];
}
_.flatMap([1, 2], duplicate);
// => [1, 1, 2, 2]