I tried to explain the problem with the javascript hoisting, but I couldn't explain the case of b
.
Didn't b = 50
modify the global variable b
?
Is it the reason for block-level scopes?
Environment
Chrome 77
{
a = 50
function a() {}
}
console.log(a) // 50
console.log(b) // undefined
{
console.log(b) // f b () {}
function b() {}
b = 50
console.log(b) // 50
}
console.log(b) // ƒ b () {}
I thought b
was 50 like a
. but it was a function.