Automatic Global Scope

Jan 7, 2018 13:20 · 39 words · 1 minute read . lroellin

Variables without any qualifier (var, let/const) are automatically in the global scope (after executing the block)

console.log(x) // x is not defined
function foo() {
    x = 5
}
// x is still not defined
foo()
console.log(x) // 5