I was working on a task related to
Custom Events and was wondering, is there a difference between these methods apart from extra argument for
I have referred Passing additional arguments in custom Event, but we can even use
event.details to set
So the question is, Is there any benefit of using specific one of them?
From the DOM spec:
initCustomEvent(type, bubbles, cancelable, detail)method must, when invoked, run these steps:
initEvent(type, bubbles, cancelable)method, when invoked, must run these steps:
- If context object's dispatch flag is set, terminate these steps.
- Initialize the context object with type, bubbles, and cancelable.
So, apart from the
detail argument, they are the same.
event.initEvent This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time. MDN
©2020 All rights reserved.