Reputation: 1481
Considering the following simple example:
_.each(activeListItems, function(element){
toggleActiveItem(element);
});
How could I pass the item from each iteration to a "external" function, like this:
_.each(activeListItems, doSomething(item) );
Upvotes: 1
Views: 168
Reputation: 2596
You're close.
_.each(activeListItems, doSomething);
function doSomething(element, index) {
console.log(element, index);
}
Upvotes: 1