Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGareth Moore
7,724 PointsA helpful thing to keep in mind about addEventListener()
There is an array of Event listeners when you open a web page.
When you use: addEventListener()
You add another event listener (register the event listener) to the array of event listeners already created. Each time an event is triggered, say a 'click', the browser will go through the entire list of event listeners to see if there is a match, and if so, execute the event handler.
This helped me a lot because I had no idea where or how to use event listeners but now, knowing that creating an event listener adds this new event to a list of event listeners, has given me some helpful insight into how they work.
This guy explains it better: https://stackoverflow.com/questions/13156096/where-is-an-event-registered-with-addeventlistener-stored