Reputation: 562
Again, i'm quite new to Javascript and Extjs.
code:
var test = [
{
id: 0,
test: 'Hello'
},
{
id: 1,
test: 'World'
}
];
how do I get the ID of each instance?.
Thanks for the reply.
Regards, Ronel
Upvotes: 0
Views: 2334
Reputation: 100195
do you mean:
for(var i = 0; i < test.length; i++) {
console.log( test[i].id);
}
or
console.log( test[0].id); //for first
console.log( test[1].id); //for second
in Extjs, you can use iterator function:
Ext.each(test, function(val, index) {
console.log(val.id)
});
OR
Ext.pluck(test, 'id'); //returns [0, 1]
Upvotes: 5