In underscore.js the for each method starts with the following:
var each = _.each = _.forEach = function(obj, iterator, context) {
How is it able to do something = something = something? I didn’t think you could do that?
See: http://documentcloud.github.com/underscore/docs/underscore.html#section-12
Thanks
That’s basically just defining aliases for the
function(obj, iterator, context)that is created.It’s the same as doing
var a = b = c = d = 0;All those vars are created and have the value 0.Though the example I gave will actually create separate objects because a number is an intrinsic type. The one in your question will create those objects that all reference the same function.