Accessing a member of an object that doesn't exist simply returns undefined on reading because the language was "designed" that way.
If instead you assign a value to it then you're creating the member.
When using an identifier that is not a local the language accesses the global window object, but first checks if the member actually exists and gives an error otherwise. This is weird but just accept it... it's this way because it's this way. There's no solid logic reason.
If you think this is questionable then be prepared for much much worse. Logic is not a really important part of the Javascript language. You should remember that Javascript wasn't indeed given any serious thought at design time (basically it was created overnight) and, as a language, is close to hideous.
The internet big bang however solidified it in its current sad state and it's not something that will be "fixed" in incompatible ways as changing it would simply break the whole world wide web. Normally "standards" are defined after a lot of thinking and experimentation but this didn't happen for Javascript and what was standardized it's that overnight hack.
Just enjoy the really fantastic runtime environment (HTML5 browsers, node js) and pay a lot of attention when writing your code.
PS: Don't even use or look the specs about what == does in Javascript. It's just nonsense.