I'm reading Douglas Crockford's Javascript the good parts,but I can't understand the implemention of Array.push in the chapter 8 Methods,as follows:
Function.prototype.method = function(name,func){
if(!this.prototype[name]){
this.prototype[name] = func;
}
};
Array.method('mypush',function(){
this.splice.apply(this,[this.length,0].concat(Array.prototype.slice.apply(arguments)));
return this.length;
});
var arr = [1,2,3];
arr.mypush(2,3);
console.log(arr);
I can't understand this statement:
this.splice.apply(this,[this.length,0].concat(Array.prototype.slice.apply(arguments)));
Any help would be greatly appreciated, Thanks