var currying = function(fun) {
//底下这句代码是什么意思?
var args = Array.prototype.slice.call(arguments, 1);
return function() {
//底下这句代码也不怎么清楚
var _args = args.concat(Array.prototype.slice.call(arguments));
return fun.apply(null, _args);
};
}
Can you explain the meaning of the code of this function? I Baidu's call method and slice method, but when they are combined and used together with the arguments object of the function, I can't figure it out. I am a newbie learning, so I don't understand some concepts very well
Forget Baidu, go directly to mdn https://developer.mozilla.org...
arguments is an array-like object, not an array, and does not necessarily have the slice method of the array, so the call method is used to enable the arguments object to call the slice method like an array.