JavaScript · Middle · Question 43 of 75
What does the { passive: true } option in addEventListener('touchmove', ...) do?
- ✓Correct answer: Promises not to call
preventDefault, so scrolling doesn't wait for the handler - 2The handler runs once and is then removed automatically
- 3The handler fires in the capturing phase instead of bubbling
Explanation
The browser doesn't know in advance whether a handler will cancel scrolling, so it waits for it to run. A passive handler lets scrolling start immediately - noticeably smoother on mobile. For a one-time handler there's once; for the capturing phase, capture.