Closure and Memory Leaks
IT Notes → Javascript @ December 22, 2020
- Returning a function literal created as an internal object within another function, and assigning it to a variable in the calling application, is known as closure in JavaScript.
-
function leakMemory() { var el = document.getElementById('el'); var o = { 'el': el }; el.o = o; }
- Accidental closure can create memory leaks as above.
Subscribe
Login
0 Comments