method

Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};

Array.method('unshift',function(){
    this.splice.apply(this,[0,0].concat(Array.prototype.slice.apply(arguments)));
    return this.length;
    
});

原文地址:https://www.cnblogs.com/dingyuanxin/p/3782246.html