This snippet results in a JavaScript runtime error: (foo is not defined)
foo
if (foo) { // ... }
I have to define foo
It seems strange question to me. Lets say I wanted to call a function:-
thing();
If thing hasn't be defined anywhere surely I would expect it to fail.
Why would you expect to use a variable called foo without defining it anywhere in your code?