What is a closure

If a function uses an external variable, then the function plus the variable is a closure

Ex. :

What is the call stack

  • Before the JS engine calls a function, it needs to push the function’s environment into an array called the call stack.
  • When the function is finished, it pops out the environment and returns to the previous environment to continue with the following code.