Remove event handler function from window?
<p>If I've added a function to the window object like this:  </p>

<pre><code>window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}
</code></pre>

<p>And lets say my code may run this snippet many times is there a danger in a memory leak? (since I never "delete" that function from the window [SPA])  </p>

<p>And just to be on the safe side I prefer to remove that function when my component dies (angularjs2 by the way) how can I "unbind" a function from the window object?</p>

<p>I hope I understand right that each time I call <code>window.onclick = function(...)</code> I <strong>add</strong> a function and not replacing one</p>