snippet 1 -> output is “b”
if (true) {
x = "b";
function x() {}
}
console.log(x); //b
snippet 2 -> output is ƒ x() {}
if (true) {
function x() {}
x = "b";
}
console.log(x); // ƒ x() {}
I know that using strict mode will not affect the global variable at all, but I want to know how x
is being assigned different values when strict mode is disabled.