skip to Main Content

Javascript – JS GC in closure

hi i have a query and was unable to get exact answer. I have a below closure function function closure() {let innerVal; return function() {innerVal = innerVal+10}} let inst = closure(); inst(); console.log('end'); will innerVal be cleared during GC after…

VIEW QUESTION

Javascript – Would event listeners prevent garbage collecting objects referenced in outer function scopes?

Let's assume I have the following code: (function () { const largeObject = provideSomeLargeObject(); const largeStaticListOfElements = document.querySelectorAll('span'); const someElementThatWillBeRemoved = document.getElementById('i-will-be-removed'); const elms = document.getElementsByClassName('click-me'); for (let i = 0; i < elms.length; ++i) { const anotherLargeObject = provideAnotherLargeObject();…

VIEW QUESTION
Back To Top
Search