documentcloud/underscore — Issue #449: _.each() does not work on Backbone.Collection instance
Author: skang
Created: 2012-01-27 21:05:09+00:00
State: open

Some how, the following iteration code does not seem to work:

var objCol = new Backbone.Collection( [{attr: 'value1'}, {attr: 'value2'}] );
_.each( objCol, function( obj ){ alert(obj); } );

But this works:

var objCol = new Backbone.Collection( [{attr: 'value1'}, {attr: 'value2'}] );
objCol.each( function( obj ){ alert(obj); } );

Is it a bug with Underscore.js or just a designed behaviour? Please disregard if it's the latter. Thanks

BTW, this happens in Underscore.js v1.3.1 with Backbone 0.5.3 collection instance. I did not test against other versions.