How to manually trigger event on element in JavaScript

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

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