简体   繁体   中英

javascript dot notation to bracket notation in array of objects

I have an array of objects and I'm looking to use google closure. I need to convert some dot notation to bracket notation.

At the moment, I'm accessing properties in a loop like this:

TheArray[i].MyProp1;
TheArray[i].MyProp2;

When I write

TheArray[i].['MyProp1'];

it doesn't convert. How do I do this conversion to bracket notation in arrays of objects.

Drop the dot.

It should just be TheArray[i]['MyProp1'];

括号直接转换为点符号 - 您正在访问对象的成员。

TheArray[i]['MyProp1']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM