Tuesday, June 19, 2018

Bracket notation requires some sort of object reference to the left of the left bracket.

(or the leftmost bracket if you are dot dot doting out to something with bracket notation without any dots as its bracket notation, duh) There is no way in JavaScript to get this to fly:

var theGr8 = "enemy of the good";
alert(["theGr" + (4 + 4)]);

 
 

Instead, we have to do something like so:

var pitfalls = {
   theGr8 = "enemy of the good";
};
alert(pitfalls["theGr" + (4 + 4)]);

 
 

Some things cannot be had at through calculated magic strings.

No comments:

Post a Comment