developer.mozilla.org/en-US/docs/Web/API/GlobalEv…
developer.mozilla.org/en-US/docs/Web/API/EventTar…
The onscroll method is more for quick methods. But there's no real difference. It's just addEventListener allows developers to assign and then remove event listeners once complete - useful for tidying up after oneself.
Trent Haynes
Weeks of coding and can save you hours of planning.
I consider them to be two ends of a path.
If you are going through a neighborhood and see the path leading from the road to the door of someone's house, you can consider that an event.
addEventListenerthe way you mark the path (or in this example the house you want to visit) the you are interested in.Your browser will raise an event in response to something... scrolling, clicking, navigating, etc. In order for code that your write to 1) know about those events 2) respond to those events, you have to listen for them.
addEventListeneris a way you can do that.