[Javascript] Subscript Notation

Terry Riegel riegel at clearimageonline.com
Fri Nov 11 06:57:31 CST 2011


Given:

a={name:'terry'}

Then:
a.name would return terry

And So Would:

a['name']

So my question. Is it possible to use subscript notation for the first part of an object something like...

['a'].name or ['a']name

Or would I have to resort to eval() to do something like that. This question is realted to my earlier one but I would be interested in an answer apart from my earlier post.

this seems to work...

eval('a').name

But eval is bad and I want to avoid it.

Thanks,

Terry


More information about the Javascript mailing list