Yes, e
is just a variable name. Actually eventListeners be default accept the event object as an argument. The e
present in argument actually gets assigned to the event object when called, similar to how a
and b
get assigned to numbers passed in the add function. When you do not have the argument, it cannot be resolved to the function with an argument (without default argument, ofcourse ). Hence, the event listener without any parameters does not work in this case because it cannot be resolved to the event listener’s call.
In simple terms, if you have the 2 parameter add function, but call add(5), with single argument. You can clearly see that it does not resolve this call to the function with 2 arguments. The eventListener calls the function with argument as event object, but it cannot be resolved to the function with no argument.
Hope this helps…
1 Like