Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript dot notation to bracket notation in array of objects

Tags:

javascript

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.

like image 930
frenchie Avatar asked Oct 21 '25 16:10

frenchie


1 Answers

Drop the dot.

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


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!