Why does it work?

let myButton = document.querySelector('#myButton');
myButton.addEventListener("click", doSomething, false);
function doSomething(e) {
    alert('is this working?');
}

Why the code works even if the “doSomething” function was defined after using it???

Due to hoisting! :tada: