_.iteratee

iteratee_.iteratee(value, [context])
Generates a callback that can be applied to each element in a collection. _.iteratee supports a number of shorthand syntaxes for common callback use cases. Depending upon value's type, _.iteratee will return:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// No value
_.iteratee();
=> _.identity()
 
// Function
_.iteratee(function(n) { return n * 2; });
=> function(n) { return n * 2; }
 
// Object
_.iteratee({firstName: 'Chelsea'});
=> _.matcher({firstName: 'Chelsea'});
 
// Anything else
_.iteratee('firstName');
=> _.property('firstName');

The following Underscore methods transform their predicates through _.iteratee: countBy, every, filter, find, findIndex, findKey, findLastIndex, groupBy, indexBy, map, mapObject, max, min, partition, reject, some, sortBy, sortedIndex, and uniq

doc_Underscore
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.