Improving Function.prototype.bind

Andrea Giammarchi andrea.giammarchi at gmail.com
Fri Jan 6 02:20:20 PST 2012


On Fri, Jan 6, 2012 at 10:50 AM, David Bruant <bruant.d at gmail.com> wrote:

>
> Your proposal won't be implemented in older browsers. Actually, it is very
> likely that your proposal would be implemented in browsers that would
> already have weak maps.
> Under these conditions. What is the benefit of a native implementation
> rather than an WeakMap based polyfill?
>
> David
>
> [1] http://code.google.com/p/es-lab/source/browse/trunk/src/ses/WeakMap.js
>
>
>
Why would you say that ? This version
https://gist.github.com/1569978should works in every browser without
problems.

I have also tested memory leaks via snapshots through the profiler ...

// snapshot, 1.2 Mb

function test(){}
for (var i = 0, a = []; i < 0xFFFF; i++) a.push({}.boundTo(test));

// snapshot 35.8 Mb
a = null;

// snapshot, 1.2 Mb

Andno WeakMap is used ... am I missing something ?

Cheers,
  Andrea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120106/96c4d554/attachment.html>


More information about the es-discuss mailing list