Function.prototype.bind behaviour (call vs apply)

Jordan Osete jor at
Thu Aug 20 13:33:00 PDT 2009

Hello everybody.

The currently proposed bind() method for function objects behaves like 
call(): it takes a number of arguments (from arguments[1] onwards), and 
uses them for the function execution.

Wouldn't it be more flexible to behave like apply(), taking an array of 
parameters instead of taking each parameter individually ?

The second approach seems more powerful to me. That is, every call() can 
easyly be replaced by apply(): thisObj, a, b, c ) -> func.apply( thisObj, [ a, b, c ] )

...But when you only have got an array of arguments, you can't go the 
other way around:
  func.apply( thisObj, argsArray ) -> /* impossible */ )

Would it be possible to change bind to behave like apply ?


Jordan OSETE

More information about the es-discuss mailing list