Skip to content Skip to sidebar Skip to footer

How Do I Get A Property Of An Object By String?

I have an object, in an array. Doing this: alert(myObject.cats[1].nickname); will output 'fluffykins' or whatever the nickname is. Is there a way to access this property by string

Solution 1:

Yes, just use square brackets as usual.

myObject.cats[1][param]

Solution 2:


Post a Comment for "How Do I Get A Property Of An Object By String?"