I'm practicing _.every from scratch to learn Javascript, and there are just two lines that I don't understand. Could you articulate what these lines are doing:
if(iterator == undefined) {
iterator = _.identity;
_.every = function(collection, iterator) {
if(iterator == undefined) {
iterator = _.identity;
}
return _.reduce(collection, function(accumulator, item) {
if (iterator(item)) {
return accumulator;
}
else {
return false;
}
}, true);
};
I know that _.identity returns the same value that is used as the passed parameter, but I'm not quite seeing how it's applicable here?