[whatwg] Polling APIs in JavaScript vs Callbacks

Garrett Smith dhtmlkitchen at gmail.com
Mon Feb 11 23:28:06 PST 2013


On 2/11/13, Garrett Smith <dhtmlkitchen at gmail.com> wrote:

[...]
>
>  var listener = {
>   handleEvent : function(ev) { console.log(ev); },
>   quant : 40
>  };
> //  or even
>  function handleEvent (ev) { console.log(ev); }
>  handleEvent.quant = 40;
>
Second example should have been
 function listener(ev) { console.log(ev); }
 listener.quant = 40;

>  var booleanParametersSuck = false;
>
>  document.addEventListener("mousemove",  listener, booleanParametersSuck);


Also, for those unfamiliar with the standard specification of
EventListener, particularly with the second parameter being an Object
with a handleEvent property that is a Function:
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener
-- 
Garrett
Twitter: @xkit
personx.tumblr.com



More information about the whatwg mailing list