Backbone: collection of models id's to an array

backbone.js, javascript

Solution

You can use the Underscore method `pluck` for this:

collection.pluck("id");

http://jsfiddle.net/upqqL/

Description of `pluck` from the UnderscoreJS docs:

A convenient version of what is perhaps the most common use-case for map: extracting a list of property values.

Problem

Is it a method in backbone that will take a collection of models and made an array of model id's or any other specified attribute in the model? I'm able to list the model's is's in the console.log but unsure how to make an array from it ``` for (var i=0; i<collection.models.length; i++){ console.log(collections.models[i].id) } ```

Original source