I’m reading the book Javascript: The Good Parts. And I’m confused by the following code.
Function.method('curry', function ( ) {
var slice = Array.prototype.slice,
args = slice.apply(arguments),
that = this;
return function ( ) {
return that.apply(null, args.concat(slice.apply(arguments)));
};
});
Where is the null in slice.apply(arguments)?
argumentsis being passed as the context (this), not the function’s arguments.It’s equivalent to
arguments.slice(), except thatarguments.slice()doesn’t exist.