Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Because I am not using the var keyword why is the variable 'local' not in the global scope in the chrome console?
function test(){ local = true; }; console.log(local);//Uncaught ReferenceError: local is not defined
test();
local = true;
It is simply because the test function is never called so the local variable is never created due to which it throws error
Add a comment
It will be available once test() is invoked
test()
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
test();. Its body, including the assignment,local = true;, won't be evaluated until then.