I can't find the difference between doing:
window.onscroll = () => console.log("scroll")
and this:
window.addEventListener('scroll', () => console.log("scroll"))
except for browser compatibility which both seems to be unsupported in most IE versions !
is it just a syntax difference? it seems that it is straightforward to remove the handler using removeEventListener
, but I'm assuming window.onscroll = null
has similar effect.
am I missing anything?