javascript - Difference between free variable and local free variable -
this question has answer here:
- what free variables? 3 answers
i reading tutorial javascript closure.there concept called free variables.free variables variables neither locally declared nor passed parameter.
the tutorial's first example:
function numbergenerator() { // local “free” variable ends within closure var num = 1; function checknumber() { console.log(num); } num++; return checknumber; } var number = numbergenerator(); number(); in example, comment said num local free variable.but above concept free variable said free variable not locally declared.i confusing that.
not sure question num availible within closure considered "private" variable of numbergenerator.
Comments
Post a Comment