How can one understand closures in Javascript?
In general terms, a closure is a function bound to one or more external variables. When it is called, the function is able to access these variables. In JavaScript, closures are often implemented when functions are declared inside another function. The inner function accesses variables of the parent one, even after the parent function has terminated
In this statement, "a closure is a function bound to one or more external variables", does it mean we can do this : var myFun = Function(msg){...};
is it correct ?
What does it mean "even after the parent function has terminated"?
No comments:
Post a Comment