I read the source code of lo-dash, and find there is fast alternative the function apply()
here.
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
I want to know is that really efficient way to implement the fast alternative function apply()
? Why there is no more than 3 args to decomposed here?