Underscore.JS 遍历集合
Underscore.JS有许多易于使用的方法,可以帮助遍历集合。本章详细讨论了这些方法。
Underscore.JS提供了以下各种遍历集合的方法 –
| 序号 | 方法和语法 |
|---|---|
| 1 | each _.each(list, iteratee, [context]) |
| 2 | map _.map(list, iteratee, [context]) |
| 3 | reduce _.reduce(list, iteratee, [memo], [context]) |
| 4 | reduceRight _.reduceRight(list, iteratee, [memo], [context]) |
| 5 | find _.find(list, predicate, [context]) |
| 6 | filter _.filter(list, predicate, [context]) |
| 7 | where _.where(list, properties) |
| 8 | findWhere _.findWhere(list, properties) |
| 9 | reject _.reject(list, predicate, [context]) |
| 10 | every _.every(list, [predicate], [context]) |
| 11 | some _.some(list, [predicate], [context]) |
极客教程