Question: I know what the following code DOES, I'm just unable to wrap my head around the WHY.

```
var myObject = new Object();
var foo = new Object();
var bar = new Object();

myObject[foo] = 'foo';
myObject[bar] = 'bar';
console.log(myObject[foo]);  // returns bar
console.log(myObject); // returns [object Object]: "bar"
console.log(myObject[blah]); // returns "blah not defined" error.

```

By this measure, how is myObject[blah] undefined yet 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> an object's properties can be accessed via `object.property` **or** `object[property]` however if I add in `myObject.foo = "foobar";` before the console logs, `myObject[foo]` does not get set to "foobar" but `myObject.foo` does.

If I console.log `myObject.Object` or `myObject.object` or `myObject[object]` or `myObject[Object]` - it all comes back as undefined.

Both foo and bar have values of `Object {}`. So they aren't being set.

Answer: 
You're referencing the variable `blah` which is not defined.

`foo` and `bar` are defined but it's very strange to use them as keys in another object. JavaScript doesn't support HashMaps by default, instead it will perform a to-string cast, this produces `"[object Object]"`.

So `myObject[foo]` and `myObject[bar]` are both just `myObject["[object Object]"]`

Did you intend `myObject["foo"]` and `myObject["bar"]`"?

The syntax is either:

```
obj["property"];
// or
obj.property;
// or
var prop = "property";
obj[prop];

```
* *By this measure, how is myObject[blah] undefined*

`myObject[blah]` is undefined because your trying to add the object blah which is not existing or **undefined** (thats what the interpreter is complaining when you open the console)

so if you would have said 

```
var blah= new Object();

```

`myobject[blah]` would have worked fine.

* *yet myObject[foo] and myObject[bar] are defined - and not only defined, but set to the same value*

The reason being similar to the above one, since you have defined foo and bar by declaring them as objects

```
var foo = new Object();
var bar = new Object();

```

the reason they have the same value is because you assigned them with those values 

```
myObject[foo] = 'foo';
myObject[bar] = 'bar';

```

* *According to <http://www.w3schools.com/js/js_objects.asp> (Try to use MDN <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Objects>)... however if I add in myObject.foo = "foobar"; before the console logs, myObject[foo] does not get set to "foobar" but myObject.foo does.*

This part has been answered well in the other two answers, but for the sake of completion.
when you say myObject.foo , it creates a new **'property'** ,if not already present, called 'foo' for 'myobject'. 

The other way when you say 

```
myobject["foo"] //-> NOTE foo is a string. A property is created.

```

However when you have

```
var foo = new object();
myobject[foo] // this is not correct since foo is an object here not a string 
//or a property. inshort adding objects as property not a good idea.

```

* *If I console.log myObject.Object or myObject.object or myObject[object] or myObject[Object] - it all comes back as undefined.*

myObject.Object // there is no property called 'Object', 'object' in myobject

However, if you say 

```
myObject.object = "added object property"; //OR
myObject["object"] = "added object property";

```

then try the above console.log commands it should work, but note that properties are case sensitive