5.0.0
function square(n) {
return n * n;
}
map([4, 8], square);
// => [16, 64]
map({ 'a': 4, 'b': 8 }, square);
// => [16, 64] (iteration order is not guaranteed)
var users = [
{ 'user': 'barney' },
{ 'user': 'fred' }
];
map(users, 'user');
// => ['barney', 'fred']
Optional
iteratee: ArrayIteratee<T, R>Optional
Optional
iteratee: RecordIteratee<T, R>Optional
Optional
iteratee: anyOptional
Creates an array of values by running each element in
collection
thruiteratee
. The iteratee is invoked with three arguments: (value, index|key, collection).Many lodash methods are guarded to work as iteratee for methods like
every
,filter
,map
,mapValues
,reject
, andsome
.The guarded methods are:
ary
,chunk
,curry
,curryRight
,drop
,dropRight
,every
,fill
,invert
,parseInt
,random
,range
,rangeRight
,repeat
,sampleSize
,slice
,some
,sortBy
,split
,take
,takeRight
,template
,trim
,trimEnd
,trimStart
, andwords