First, closure concept understanding
Various professional literature on the JS "closure" (closure) definition is very abstract, thieves ugly understand. My understanding is that closures are functions that can read the internal variables of a function. Because only functions inside the function in the JavaScript language can read local variables, closures are simply understood as "functions defined inside a function". So, in essence, a closure is a bridge that connects the inside of the function to the outside of the function.
Second, the use
Closures can be used in many places. But it has two of its maximum usefulness, one of the variables mentioned earlier that can read inside a function, and the other is to keep the values of those variables in memory.
Third, the use of closures precautions
1, because the closure will make the variables in the function is stored in memory, memory consumption is very large, so can not abuse closures, otherwise it will cause the performance of the Web page.
2. The closure will change the value of the internal variables of the parent function outside the parent function and use it cautiously.
JS Closure (closure), personal understanding