How to manually trigger event on element in JavaScript

DOM
By Jad Joubran · 
Last updated Mar 11, 2018
<button id="submit"></button>
const button = document.querySelector("#submit");

//trigger click
button.dispatchEvent(new Event("click"));
Events on MDN