Saturday, August 31, 2013

Previous Interview Question Next Interview Question
Home

Explain Javascript closures ?

A basic overview of javascript closures is that it is a stack-frame which is not de-allocated when the function returns.

A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variables.
The inner function has access not only to the outer function’s variables, but also to the outer function’s parameters. Note that the inner function cannot call the outer function’s arguments object, however, even though it can call the outer function’s parameters directly.
You create a closure by adding a function inside another function.

Previous Interview Question Next Interview Question
Home

0 comments :

Post a Comment