Possible Duplicate:
How do JavaScript closures work?
function add(num){
return function(num1){
return function(num2){
return num + num1 + num2;
};
};
}
var add5 = add(7)((7))((7));
console.log(add5);
I've experimented quite a bit with JavaScript because I'm trying to grasp how closures work.
But then I've tried this
var add5 = add(7)((7))((7));
console.log(add5); //result is 21
The way I see it, are closures a kind of pointers to the outer function or its parent function?