4.17.11
3.10.1
2.4.2
1.3.1
_.invokeMap(collection, path, [args])
Invokes the method at path
of each element in collection
, returning
an array of the results of each invoked method. Any additional arguments
are provided to each invoked method. If path
is a function, it's invoked
for, and this
bound to, each element in collection
.
Since
4.0.0
Arguments
argument
collection
path
[args]
type
(Array|Object)
(Array|Function|string)
...*
description
The collection to iterate over.
The path of the method to invoke or the function invoked per iteration.
The arguments to invoke each method with.
Returns
(array)
Example
_.invokeMap(
[
[5, 1, 7],
[3, 2, 1],
],
"sort"
);
// => [[1, 5, 7], [1, 2, 3]]
_.invokeMap(
[123, 456],
String.prototype.split,
""
);
// => [['1', '2', '3'], ['4', '5', '6']]
_.invokeMap(
[
[5, 1, 7],
[3, 2, 1],
],
"sort"
);
// => [[1, 5, 7], [1, 2, 3]]
_.invokeMap([123, 456], String.prototype.split, "");
// => [['1', '2', '3'], ['4', '5', '6']]