Function.prototype.bind = function(){
var fn = this,
// clone arguments
args = Array.prototype.slice.call(arguments),
// get the first argument, which should be an object, and args will be modified.
object = args.shift();
return function(){
return fn.apply(object,
// why use concat??? why?
args.concat(Array.prototype.slice.call(arguments)));
};
};
...
elem.onclick = Button.click.bind(Button, false);
....
I saw above code from here: http://ejohn.org/apps/learn/#86 while learning javascript. The code is an excerpt from prototype.js. The comments are added by me, not from original code.
My question is why use args.concat(Array.prototype.slice.call(arguments)))? I think pass args is enough. The bind() in prototype.js must have its valid reason. Please help me understand it. Thank you!