I am a beginner to Javascript. And when I was practicing I have noticed something.
Take this function:
No, event
is not a reserved word. It is, however, a variable which is set by all the major browsers when an event handler (such as onkeypress) of a DOM node is being executed. In IE, it is also a global variable.
A typical cross-browser way to get the event is along these lines.
On the DOM node:
Click me
The event handling function:
function someFunction(evt) {
var srcElem = evt.srcElement || evt.target;
// Code continues
}
By the way, in your example, oEvent
is the name of the parameter and is therefore valid in the context of the function being called, not in the context of the caller.