ProllyGeek
ProllyGeek

Reputation: 15836

Dynamically calling object properties

I have an object which is a member of an array called parameters , and the this object has a property called item_ , now if I assign a value to that property , how can I call it ?

for(ss=0;ss<=parameters[gpc].children_count-1;ss++)
{
parameters[gpc]['item_'+ss]="hello";
//console.log(parameters[gpc].item_0)

parameters[gpc].message+="\t\t&lt;item value=&quot"+parameters[gpc].item_+ss+"&quot /&gt;"
}

I tried eval() but in vain.

Upvotes: 0

Views: 39

Answers (1)

MaGnetas
MaGnetas

Reputation: 5008

You can try and access it as associative array value:

var x = parameters[gpc]['item_' + ss];

Just like you assign the value.

Upvotes: 3

Related Questions