If we just wanted to pass the event object from an event listener to an event handler, this could be done without setting any parameters.
For example:
mobileInput.addEventListener('keydown', validateMobile);
function validateMobile(event) {
const keyCode = event.which ? event.which : event.keyCode;
// etc.
}
But what if, besides the event object, we also want to pass another parameter?
This can be done easily. And with an arrow function - also while keeping the code clean:
mobileInput.addEventListener('keydown', (event) =>
validateMobile(event, anotherParam)
);
function validateMobile(event, anotherParam) {
// Both the event object and anotherParam are available.
}