addEventListener Options Playground

Type addEventListener’s third argument for the teacher and the class light switch: capture, once, passive and signal read by the real browser, including a…

Why it matters

One-off handlers with no manual cleanup, catching an event before its children do, smooth scrolling on phones, and tidy component cleanup: each is one object in the third argument. signal is also the only way to remove an inline function.

The key idea

The third argument changes when, how often and until when a listener runs

Common mistakes

Try it in this playground