I learned in one of the kyle simpson's javascript courses that if we declare a variable inside a Javascript function without any prefixing var keyword, then that variable is made available in global execution context, but when I try it in chrome developer tool or nodejs it throws ReferenceError:....
Has anything changed ?
Happens in both Firefox and Chrome on Windows and Linux.
function foo() {
bar = "I am in global scope";
}
foo();
console.log(bar);
ReferenceError: bar is not defined
The other question is about undefined being appended to the output log,I do not have any mention of it in this question. Not sure why this is marked as duplicate. This question is about global execution context / scope
Thanks.