Home > front end >  JavaSrript closures
JavaSrript closures

Time:09-28


Generally by default, our function, in has been completed function space in the program will also be destroyed

This time we can to solve the problem via a closure,

So how to define the retreat
First we within the function returns a reference to the data type is (array, object, function)
Then, on the function outside, with variable to reference the function
This time we will define a space not be destroyed the execution of the

Let's take a look at the code


Code we define a function first and then used in this function returns a function is the function of fun1 private scope we can use a variable to assign a value, and then return to this variable at that time we get is a not destroyed the execution of the space
  • Related