I was reading about hoisting in mozilla, and noticed an example explaining how a variable can leak outside of the function scope: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#Initialization_of_several_variables
The example says,
var x = 0;
function f(){
var x = y = 1; // x is declared locally. y is not!
}
f();
console.log(x, y); // 0, 1
// x is the global one as expected
// y leaked outside of the function, though!
I don't understand what is happening here. I am looking for a technical explanation more than anything. How is y accessible outside at this point?
Edit: I understand how this function is behaving, and I should clarify and say I wanted an understanding of what is happening in the code and memory (ex, pointers, etc..).