[Javascript] Subscript Notation

Mike Dougherty mdougherty at pbp.com
Fri Nov 11 08:13:56 CST 2011


On Fri, Nov 11, 2011 at 7:57 AM, Terry Riegel
<riegel at clearimageonline.com> wrote:
> So my question. Is it possible to use subscript notation for the first part of an object something like...
>
> ['a'].name or ['a']name

if you have declared those objects in the scope of the window object,
you could do something like this:
var myobject = { name: 'terry' };
var whatobject = 'myobject';
var whatproperty = 'name';

alert( window[whatobject][whatproperty] );

if you're using a namespace object, replace "window" with your namespace.


More information about the Javascript mailing list