I cannot decide how to update a global variable from YUI3.
Consider the following code:
window.myVariable = 'data-one';
var yuiWrap = YUI().use('node',function(Y) {
console.log(window.myVariable);
window.myVariable = 'data-two';
console.log(window.myVariable);
});
console.log(window.myVariable);
Can someone explain this to me? It causes me a lot of trouble. Why can the .myVariable window be accessed but not properly updated from the YUI3 block?
I think this may have something to do with Closures , but I don’t understand why Closures should be applied to the global “window” object.
reference
source
share