Miguel Ehrstrand
Miguel Ehrstrand

Reputation: 71

Backbone.js How to iterate collection in descending order

I have a collection and I want to loop through it but starting from the last index to the first. Is it possible? How?

Upvotes: 0

Views: 293

Answers (1)

skay-
skay-

Reputation: 1576

You can do the following:

bc.chain().reverse().each(function(item){console.log(item)});

That will 'chain' the collection, reverse it and iterated over the reversed version.

Hope that helps.

Upvotes: 1

Related Questions