聲明一個對象听系,把方法寫在原型上
var CheckObject = function(){};
CheckObject.prototype = function(){
checkName : function(){
return this;
},
checkEmail : function(){
return this;
}
}
var a = new CheckObject();
a.checkName().checkEmail();
抽象統(tǒng)一的添加方法
Function.prototype.addMethod = function(name,fn){
this[name] =fn;
}
var methods = new Function();
methods.addMethod("checkName",function(){
console.log("chengchao")
});
methods.chekcName();