What are the disadvantages of JavaScript closure
This article mainly introduces the shortcomings of the JavaScript closure of the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe you read this JavaScript closure what the shortcomings of the article will have a harvest, let's take a look at it.
Shortcoming
1. Resident memory will increase the usage of memory, and improper use can easily lead to memory leakage.
2. It is unwise to create functions in other functions if not needed, because closures have a negative impact on script performance, including processing speed and memory consumption.
Example
Function fun (n a.fun o) {console.log (o); return {fun: function (m) {return fun (m);}};} var a = fun (0); / /? a.fun (1); / /? A.fun (2); / / a.fun (3); / /? Var b = fun (0) .fun (1) .fun (2) .fun (3); / /? Var c = fun (0) .fun (1); / / c.fun (2); / / c.fun (3); / /? This is the end of the article on "what are the shortcomings of JavaScript closures?" Thank you for reading! I believe you all have a certain understanding of the knowledge of "what are the shortcomings of JavaScript closures". If you want to learn more, you are welcome to follow the industry information channel.