In js closures, "local variables" can be defined, but calling them externally, especially repeated assignment calls, will cause a lot of memory overhead. How to prevent this phenomenon from happening? Are there any similar memory or efficiency issues to be aware of regarding closures? How to avoid it?
Memory problems may be caused by the following reasons:
1. Circular reference causes memory leak
2. Memory leak caused by external function call
Avoid memory leaks
1. Break circular references
2. Add another closure
3. Avoid closure itself
The above is the entire content of this article, I hope you all like it.