1
alert(foo) //ReferenceError: foo is not defined
alert(window.foo) //undefined

Because of foo === window.foo, I think alert(foo) should have the same behavior as window.foo.

what's the difference between foo and window.foo ?

what happened when alert(foo) ?

tks

looping
  • 1,141
  • 3
  • 11
  • 20
  • you need to define variables before you use them or else it will throw. you can check any old object, including window, for any old property, and if it's nothing that the result is undefined instead of error. – dandavis Jan 03 '14 at 08:17
  • I found the answer [here](http://stackoverflow.com/questions/10102862/referenceerror-and-the-global-object). keywork: Reference Error – looping Jan 03 '14 at 08:51

0 Answers0