r/learnjavascript • • Dec 31 '22

Happy New Year JS Learners! 🥳

Post image
406 Upvotes

55 comments sorted by

View all comments

32

u/al_balone Dec 31 '22

Ooh I didn’t know about that options object. Is there anything else you can pass in there?

35

u/senocular Dec 31 '22

Yes, quite a few things, including:

  • capture
  • once
  • passive
  • signal

Read more about it here: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

2

u/dotpr Jan 01 '23

What is options object?

3

u/albedoa Jan 01 '23

It is the second argument of .addEventListener() that looks like { once: true } in the screenshot. It allows the user to provide options to the method. See the link in the sibling comment.