Improving Function.prototype.bind

Brendan Eich brendan at
Mon Jan 9 08:08:50 PST 2012

On Jan 9, 2012, at 12:29 AM, David Bruant wrote:

> Le 09/01/2012 06:29, Brendan Eich a écrit :
>> On Jan 8, 2012, at 7:20 PM, John J Barton wrote:
>>> On Sun, Jan 8, 2012 at 3:35 PM, Brendan Eich <brendan at> wrote:
>>>> Firebug uses a library bind a lot, and we continually struggled with the memoization problem; we did not try to solve it in part because we hated Firebug's bind: it made debugging even more painful since it messes up the call stack. Using the ES bind() ends up not being a win, since I now have exactly the same problems.
>>> I have a question: why is bind used so much in Firebug for event listeners, when the DOM guarantees to dispatch them with the event target bound to |this|? Way back in '95, I created event handlers but did not add bind (it had to be discovered later). But dynamic |this| binding combined with DOM event target-based listening and handling kept this properly bound. What has changed?
>>> Sorry I don't know what you mean here.
>> Why all the this-binding in Firebug if (as you suggested and a grep seems to confirm [but I skimmed]) the methods being this-bound are all or mostly event listeners? The DOM dispatches event handlers on the correct |this|.
> Relevant related documentation:

Do you mean this "(some browsers do not follow this convention for listeners added dynamically with methods other than addEventListener)." part? Ghastly but not browsers Firebug targets (namely, Firefox), right? 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list