|
|
|
|
|
by Pephers
4155 days ago
|
|
Yes, you can. I've successfully done so in a Backbone/React app. The _.chain() method furthermore gives a nice functional style ways of building lists which is useful when building UI in React, like so: var list = _.chain([1, 2, 3, 4, 5])
.filter(function (value) {
return value > 2;
})
.map(function (value) {
return value;
});
console.log(list);
// prints:
// [3, 4, 5]
|
|
Also your code was broken in Lodash 2 (it'd return a lodash object, not a list) and is more broken in Lodash 3 (chains are now lazy), so your code does just about nothing until you force the iterator's evaluation)