I'm updating a variable from an outer scope in a nested function,
as this is happening during a init function the outer scope isn't the outermost (window) scope;
var init = function() {
var x = 'old stuff' ;
function butClick() {
x = 'new stuff' ;
}
console.log(x); // new stuff
document.querySelector("btn").addEventListener("click", butClick, false);
}
window.addEventListener( 'DOMContentLoaded', init, false);
in order to save it in the init-function scope I'm omitting the var keyword and as expected the new value of the variable bubbles up and updates;
but the result of console.log('x' in window )
is false,
isn't the bubbling supposed to get to the window scope?