Are there any drawbacks to using anonymous functions in JavaScript? E.g. memory use?

后端 未结 3 1075
北海茫月
北海茫月 2021-02-01 15:16

At some point in the past, I read something that gave me the idea that anonymous functions in JavaScript can use up a surprising amount of memory (because they carry th

3条回答
  •  渐次进展
    2021-02-01 15:48

    I think what you probably read about was the IE closure memory leak problem.

    Look at this article on the issue.

    Basically, on older versions of IE, the garbage collector could not handle circular references involving DOM objects. Since closures are very conducive to such circular references, they could easily lead to annoying memory leaks in IE.

提交回复
热议问题