'event' as an argument


Hi everybody I would like to further understand how adding event as an argument works. I'm not getting why we add that as an argument


The name of the variable is arbitrary. It is very common to name it event since that is what it references... The event object instance. This object contains all the data relating to the event and giving it a name in the parameter lets us access the object inside the event handler function.

When we invoke the handler function JS creates a scope object to which it adds the arguments and other local variables. We haven't defined the variable as much as just declared it. JS populates the data on each event.

Events are transient and the internal event object is constantly updated with each new event. I'm not certain that there is no rollback or history, although I doubt it.