04-23-2009, 05:39 PM
|
#3 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by allworknoplay
Now I keep staring at that code, and I don't see what he's talking about? The function has only one variable in it's scope, and that's the Y variable in which he returns it.
|
Sure, there's only one variable used (aside: not declared) inside the function but the variable x is still available to be used. For example:
JavaScript Code:
var x = 5; var n = function(){ var y = 10; return x + y; };
// … some time later x = 113; alert(n()); // 123
|
|
|
|