Regarding the code below, how does the interpreter know that event has attribute .keyCode. This code works, I just don’t understand completely why, and more so were is this documented. How does it know what type of object event is. What if I would have called it ‘e’ or ‘e1’. Where is the method prototype f1(Event) documented?
function b0(event)
{if (event.keyCode==13)
{i4();
return false;}}
function o5('f4b_',b0);
o5(a,b){document.getElementById(a).onkeypress=b;}
where the element id a is an input text box.
The name of event is irrelevant, inside the function it’s just another variable. You can rename it to JellyMan, and if you rename
if (event.keyCode==13)toif (JellyMan.keyCode==13)it will work fine.The type of event is determined by the script at run-time. The interpreter does not know that event has an attribute of .keyCode – if you tried to call it, and passed in a parameter that isn’t the correct type:
b0('wheee, break it');then it will fail.When the author wrote the script, he decided that function b0 would take one parameter (he called it event) and it would be a eventHandler – this doesn’t get specified anywhere, it’s just assumed that nobody’s going to call it with something else. All eventHandlers have a .keyCode attribute, so it’s therefore assumed that the object being passed in has one.