|
|
|
|
|
by vaughanhedges
5468 days ago
|
|
'y' remains as such because it hasn't been bound to a value just yet. That's easy enough to test. var y=20; function foo(x) {
var tmp = 3;
var y = 20;
return function (y) {
alert(x + y + (++tmp));
}
}var bar = foo(2); // bar is now a closure. bar(10); This makes no difference.
The alert runs once, and displays 16. |
|