I know what the following code does, I just can't wrap my head around WHY.
var myObject = new Object();
var foo = new Object();
var bar = new Object();
myObject[foo] = 'foo';
myObject[bar] = 'bar';
console.log(myObject[foo]);
console.log(myObject);
console.log(myObject[blah]);
To this extent, how is myObject [blah] undefined, but myObject [foo] and myObject [bar] are defined - and not only defined, but set to the same value?
According to http://www.w3schools.com/js/js_objects.asp the properties of the object can be obtained through object.property or object[property] , however, if I add in myObject.foo = "foobar";front of the console logs, myObject[foo]it is not set to "foobar", but myObject.foodoes.
If I console.log myObject.Objector myObject.Objector myObject[object]or myObject[object]- it all returns as undefined.
foo bar Object {}. .