When was the closure generated?

when is the closure generated? Is it when the function is defined or when it is executed?

= add =
from "JavaScript you don"t know". There is no free variable in the callback of click binding, so why is it a closure?

Mar.25,2022

scope is generated when the function is defined, and references to variables in the outer scope produce closures


http://liximomo.github.io/jav...


closure, actually refers to the closure function, refers to a function using variables outside the scope of the function, the function is called the closure function. For example:

let name = 'test';
//  
// 
function say(){
    //   name
    console.log(name);
}
Menu