In this article, let's move on to the execution context , Mainly JS Closure sum in this There are two parts of the mechanism . Although we still start from the norm , But in fact, these two things are not mentioned much in the conceptual specification , In practice, the water is very deep , Easy to grasp , So this article is more about examples .
Closure （closure） This term is used in computers , The original meaning is “ Used to describe λ A set of information about an expression and its execution environment ”. Considering the prevalence at that time, based on λ The functional programming language of calculus ,λ Expressions can actually be extended to what we call today “ function ”.
Let's start with a piece of code ：
// Function definition function foo()