Reputation: 27
In a non-array attribute of an object:
function myObj()
{
this.code = "code";
this.name = "name";
}
I can retrieve their values using:
myCode = myObj.code;
or:
myCode = myObj["code"];
With arrays:
function myObj()
{
this.code = ["code1","code2"];
this.name = ["name1","name2"];
}
I have to to get "code2" so my syntax should be:
myCode = myObj.code[1];
Now my problem is, how can I get "code2" using the other way (the one the uses braces and the attribute enclosed in braces)?
Upvotes: 0
Views: 146