Improving Function.prototype.bind

Andrea Giammarchi andrea.giammarchi at
Fri Jan 6 08:34:31 PST 2012

If the case I show is not a problem, as you see with AMD loaders and decent
practices the problem does not exist with my approach while problems like
this exists today everywhere for those exposed objects through namespaces
or even modules.

Attaching instances properties runtime to bound functions has same impact
of what Mark considered harmful and it remains like that with current
patterns to trap boundOnce methods.

I believe after dunno how many years of listeners add/remove where I have
in first place always attached or stored the boundOnce, where necessary,
via Function#bind after or via closures and "self" as reference before,
there is a reason if I am promoting this approach and I would like to see
it solved properly, and as fast as possible, in core, keeping WeakMap shims
whenever necessary for older browser.

I understand this is not priority for ES.Next ... just try to imagine for
me the whole Class thingy is not priority at all while these solutions for
such Event driven development environment as JS is are way more interesting
for me.

Anyway, I showed the proposal and my concerns on current patterns, I think
it's enough for you or TC guys to at least consider if it makes sense to
put it there or not.

Best Regards

On Fri, Jan 6, 2012 at 5:08 PM, David Bruant <bruant.d at> wrote:
> Of course, the case you show is not a problem. The problem arise when 2
> potentially malicious scripts have access to the same object (Mark used
> 'Object' as an example).
> But with modules, module loaders and the end of global scope, I wonder to
> what extent this happens. i'll answer directly to Mark message to discuss
> this.
> David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list