Using function.prototype.bind without breaking function.prototype.apply

Mark S. Miller erights at
Wed Sep 7 14:52:08 PDT 2011

On Wed, Sep 7, 2011 at 2:46 PM, Jake Verbaten <raynos2 at> wrote:

> var f = function() { return this; }
> var g = f.bind(???);
> g.apply({ "foo": "bar" }).foo // expect "bar"
> Function.prototype.bind set's the thisArg to a certain value. Is there any
> way to leave it flexible to be overwritten using `.call` and `.apply` later
> on?
> Is there any ES:Harmony/strawman proposal for this?
> If there is not I propose using `undefined` to tell Function.prototype.bind
> to leave thisArg flexible.

We cannot use 'undefined' for this, as we already use f.bind(undefined) in
order to ensure that f's "this" is useless, and therefore harmless.

Altogether, what you're asking for is similar to <>, which, as you
see, can be implemented as a JS library. I suspect your weaker bind could
use the same technique, and so needs no new support from the language.

> The use case would be using .bind to curry parameters without effecting
> this.
> _______________________________________________
> es-discuss mailing list
> es-discuss at

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

More information about the es-discuss mailing list