声明一个对象,把方法写在原型上
var CheckObject = function(){};
CheckObject.prototype = function(){
checkName : function(){
return this;
},
checkEmail : function(){
return this;
}
}
var a = new CheckObject();
a.checkName().checkEmail();
抽象统一的添加方法
Function.prototype.addMethod = function(name,fn){
this[name] =fn;
}
var methods = new Function();
methods.addMethod("checkName",function(){
console.log("chengchao")
});
methods.chekcName();