JS Quiz answer: Option 2 (B).
Correct choice: myButton.addEventListener(‘click’, handleClick);
Why:
The standard and modern way to attach an event listener to a DOM element in JavaScript is using addEventListener(). It allows multiple listeners for the same event type on a single element. Options 1 and 3 are non-standard methods, and Option 4 (attachEvent) is an older, Internet Explorer-specific method.
Go deeper:
Using JavaScript Prototype To Add New Properties
First-answer leaderboard
- @emmawalter5 - 11 (firsts)

- @kirupa - 8 (firsts)
- @Apexcodes - 6 (firsts)
- @adnanahmed - 2 (firsts)