JSFiddle - React, Tailwind, and code Playground

HTML

<button id="button" type="button">Button</button>

JavaScript

var button = document.getElementById('button');

button.addEventListener('foobar', function() {
    console.log(arguments);
});

button.addEventListener('click', function() {
    console.log(arguments);
});

button.click({ foo: 'bar' });

var event = document.createEvent('HTMLEvents');
event.initEvent('foobar', true, false);
button.dispatchEvent(event, { foo: 'bar' });