|
|
|
|
|
by Dylan16807
4733 days ago
|
|
You have two closures that share a variable. Think about nesting it deeper. var a = function() {
var z = "foo";
window.getz = function() { return z; };
var b = function() {
var y = "bar";
window.n = function() { z = y; };
};
var c = function() {
var y = "baz";
window.m = function() { z = y; };
};
b();
c();
};
a();
Now function window.n and window.m have completely different closures that happen to share the upvalue 'z', but do not share the upvalue 'y'. |
|
I had understood your comment to mean that closures don't share variables, and I was just explaining that they certainly can. Maybe I'd misinterpreted what you were trying to say...