In a curry function like this :
var curry = function() {
var slice = Array.prototype.slice,
args = slice.call(arguments),
fn = args.shift();
return function(){
return fn.apply(null, args.concat(slice.call(arguments)));
};
};
is there any difference between this or null in fn.apply ? I don't see a case where it could make a difference.
EDIT :
Thanks to this answer I think it's pretty clear now, here is a little example I made to undersand it :
function msg() {
console.log(this.name);
}
var foo = { name: "foo"};
var msg_this = curry_this(msg);
var msg_null = curry_null(msg);
msg_this(); //msg.call(null) -> undefined
msg_null(); //msg.call(null) -> undefined
msg_this.call(foo); //msg.call(foo) -> foo
msg_null.call(foo); //msg.call(null) -> undefined
with curry_this returning fn.apply(this,... and curry_null returning fn.apply(null...
thisinside of the function stand for. You could put there any arbitrary object too.this: developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/….thisbut I didn't see how it could matters in this function