Re: Terminology: “non-method function”

Wes Garland wes at page.ca
Wed Apr 11 13:32:13 PDT 2012


>From a developer's POV - the terms bound/unbound makes a create deal of
sense, since already have bind, which effectively turns an unbound function
into a bound function.  It basically completes the thought and makes it
easy to explain.

Heck, it even makes this behaviour easy to explain:

function ABC()
{
  this.hello = "world";
}
ABC.prototype.def = function() { alert(this.hello) };
window.onclick = new ABC().def;

Q: Why does my program alert undefined?
A: The default behaviour for an event handler is to bind the event itself
as 'this'. If you wanted that program to alert "world", you should have
used a *bound function* instead.

Wes

-- 
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120411/a1ee099a/attachment-0001.html>


More information about the es-discuss mailing list