Garbage Collector won't clear removed from DOM element if it has some reference in code. But what if this reference is inside attached to this element listener?
<span id="element">aga</span>
<script>
function attach() {
var element = document.getElementById("element");
element.addEventListener("click", function() {
//1) if element isn't used in this function
console.log('aga');
//2) if element is used in this function
console.log(element);
});
}
attach();
document.body.innerHTML = '';
</script>