Event Listener Syntax
Multiple Choice Easy
Question
What is the second argument to addEventListener?
Hint
First argument is the event name, second is what to do.
Explanation
addEventListener takes the event type as the first argument and a callback function as the second. The callback receives an Event object. An optional third argument can be a boolean (useCapture) or options object. Example: btn.addEventListener("click", () => console.log("clicked")).
Related Resources
Related Lessons
- Event Handling
Learn event handling.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.