js设计模式---面向对象

来源:互联网 发布:php二次开发难吗 编辑:程序博客网 时间:2024/06/01 10:13

var CheckObject = function(){};CheckObject.prototype = {checkName:function(){//validate codereturn this;}checkEmail:function(){//validate codereturn this;}checkPassword:function(){//validate code return this;}}//use the methodvar a = new CheckObject();a.checkName().checkPassword().checkEmail();//bind on functionFunction.prototype.addMethod = function(name,fn){this[name] = fn;}//usevar methods = new Function();methods.addMethod('checkName',function(){//validate codereturn this;});methods.checkName();


0 0
原创粉丝点击