I have a simple question about Javascript Closures:
The following function is given:
function outside() {
var out = 0;
function inside() {
out +=1;
}
return inside;
}
var ref = outside();
ref();
ref();
If I call the function 2 times, out
is equal to 2.
Why is out
not overwritten by the statement?
var out = 0;