var func = tool[ev.type];
if (func) {
func(ev);
}
Note that the hash object is toolused to store function references, not scalars, such as 1, "string", etc. A feature of Javascript is that you can create, save, and pass functions at runtime.
@ , an_obj ['unknown_key'] == undefined, null.
, foo ['a_key'] - foo.a_key - 'a_key' 'foo'.
, , Javascript . , , Hash, .
( , ). tool. :
startedmousedown, mouseup mousemove
, . , tool , . .