View Single Post
Old 12-15-2012, 08:04 PM   PM User | #6
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Code:
but I don't get the whole idea of why tool[ev.type] is an array
In JavaScript, objects are associative arrays.

Code:
var myObject = { "name": "Bob" };
// can be referred to as either
myObject['name'] // or 
myObject.name
But functions are also objects and can be assigned as attributes (properties) of an object:
Code:
myObject.func = function () { alert("Hello!") };

var anOther.func = myObject['func'];
anOther.func();  // Hello!
ev is the event object which, I assume, will have the 'type' of onclick, onmouseover, etc.. which is, in turn, a function. So,
Code:
func(ev);
triggers the event-handler of this name (handing over the current event object as a parameter).

These are general details - I didn't examine the page in detail.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS

Last edited by AndrewGSW; 12-15-2012 at 10:11 PM..
AndrewGSW is offline   Reply With Quote
Users who have thanked AndrewGSW for this post:
coffeecup (12-15-2012)