First-Class Functions
Functions are first-class; they are objects themselves. As such, they have properties and can be passed around and interacted with like any other object.
Inner Functions And Closures
Inner functions (functions defined within other functions) are created each time the outer function is invoked, and variables of the outer functions for that invocation continue to exist as long as the inner functions still exist, even after that invocation is finished (e.g. if the inner function was returned, it still has access to the outer function's variables) — this is the mechanism behind closures within JavaScript.
Functions are first-class; they are objects themselves. As such, they have properties and can be passed around and interacted with like any other object.
Inner Functions And Closures
Inner functions (functions defined within other functions) are created each time the outer function is invoked, and variables of the outer functions for that invocation continue to exist as long as the inner functions still exist, even after that invocation is finished (e.g. if the inner function was returned, it still has access to the outer function's variables) — this is the mechanism behind closures within JavaScript.
No comments:
Post a Comment