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); }; }; )();
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 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
David-Sarah Hopwood wrote:
... if the missing } on the last line is corrected.