While browsing the MDN page on Creating and Triggering Events, I came across an example showcasing the creation of events using Event
or CustomEvent
. The article mentions that CustomEvent
allows for custom details, but doesn't elaborate much on the differences between the two.
So, I'm left wondering - what exactly sets them apart? Should I opt for CustomEvent
when creating a generic scroll event, or is it specifically designed for events not inherent to JavaScript?
Furthermore, I also discovered that MouseEvent
is a child of Event
. Does this mean that when creating a click event, I can simply use new MouseEvent('click')
?
Any insights on this topic would be greatly appreciated. Thank you!