There’s an alternative way of writing anonymous functions, which we call an arrow function. An arrow function uses () =>
instead of function ()
:
function using function ();
document.querySelector("html").addEventListener("click", function () {
alert("Ouch! Stop poking me!");
});
function using arrow function;
document.querySelector("html").addEventListener("click", () => {
alert("Ouch! Stop poking me!");
});
Reference
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics