Function.prototype.bind behaviour (call vs apply)

Jordan Osete jor at
Sun Aug 23 02:49:26 PDT 2009

Juriy Zaytsev wrote:

> If `boundArgs` is an array of arguments to bind, then I think you 
> should be able to do this via something like:
> Function.prototype.bind.apply(targetFn, [thisArg].concat(boundArgs));
No offense meant, but I find this quite ugly and not much readable. ;-)
> // or maybe:
> boundArgs.unshift(thisArg);
> Function.prototype.bind.apply(targetFn, boundArgs);
> Which is not very elegant of course (first version also takes a 
> performance hit by creating unnecessary Array object).
Same thing, and it forces you to alter boundArgs.

Brendan Eich wrote :
> But it gets the job done.
> I think it's better to leave ES5 Function.prototype.bind as specified, 
> based on Prototype's bind (and others like it), which take positional 
> arguments to partially apply.
Yes, that's what Allen Wirfs-Brock told me, though it wasn't forwarded 
to the list. I included my reply to his message as an attachment.
> Then with spread ( 
> ) in Harmony, 
> you can write foo.bind(thisArg, ...argsArray) instead of the above 
> bind.apply mouthful.
> /be
I have to admit spread looks quite exciting to me, unfortunately it 
won't be widely implemented and usable before long.

The mail I sent to Allen is included as an attachment.


Jordan OSETE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
An embedded message was scrubbed...
From: Jordan Osete <jor at>
Subject: Re: Function.prototype.bind behaviour (call vs apply)
Date: Fri, 21 Aug 2009 23:16:43 +0200
Size: 8242
URL: <>

More information about the es-discuss mailing list