Function.prototype.bind [correction]

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Wed Sep 10 10:17:08 PDT 2008


David-Sarah Hopwood wrote:
> So, is this a valid self-hosting specification of bind?
> 
>   (function() {
>     use lexical scope;
> 
>     Function.prototype.bind = function(self, var_args) {
>       const thisFunc = this;
>       const leftArgs = Array.slice(arguments, 1);
>       return function(var_args) {
>         const args = leftArgs.concat(Array.slice(arguments, 0));
>         return Function.apply(thisFunc, self, args);
>       };
>     };
>   )();

... if the missing } on the last line is corrected.

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list