js原型鏈demo

Function.prototype.method = function(funcName,callBack){
        this.prototype[funcName] =  callBack;
        return this;

}

Number.method("integer",function(){

return Math[this > 0 ? "ceil" : "floor"](this);
});

String.method("trim",function(){

return this.replace(/^\s+|\s+$/);

});
發佈了296 篇原創文章 · 獲贊 44 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章