I am reading a tutorial about javascript closure.There is a concept called free variables.Free variables are variables that are neither locally declared nor passed as a parameter.
The tutorial's first example:
function numberGenerator() {
// Local “free” variable that ends up within the closure
var num = 1;
function checkNumber() {
console.log(num);
}
num++;
return checkNumber;
}
var number = numberGenerator();
number();
In this example, the comment said num is a local free variable.But the above concept about free variable said a free variable is not locally declared.I am confusing about that.