I asked a question about Currying and closures were mentioned. What is a closure? How does it relate to currying?
If you are from the Java world, you can compare a closure with a member function of a class. Look at this example
var f=function(){
var a=7;
var g=function(){
return a;
}
return g;
}
The function g
is a closure: g
closes a
in. So g
can be compared with a member function, a
can be compared with a class field, and the function f
with a class.