Function.prototype.method = function(funcName,func){ this.prototype[funcName] = func; return this; } Function.method("inherits",function(parent){ var depth = 0; var proto = this.prototype = new parent(); this.method("uber",function uber(name){ var func; //要执行的函数 var ret; //函数返回数 var v = parent.prototype; //父对象的prototype if(depth){ for(var i = depth; i > 0; i--){ v = v.constructor.prototype; } func = v[name]; }else{ func = proto[name]; if(func == this[name]){ func = v[name]; } } depth++; ret = func.apply(this,Array.prototype.slice.apply(arguments,[1])); depth--; return ret; }) return this; }); Function.method("swiss",function(parent){ for(var i = 1; i < arguments.length; i ++){ var name = arguments[i]; this.prototype[name] = parent.prototype[name]; } return this; }); function Person(value){ this.setValue(value); }; Person.method("setValue",function(value){ this.value = value; return this; }) Person.method("getValue",function(){ return this.value; }) function Student(name,age,value){ this.name = name; this.age = age; this.value = value; }; Student.inherits(Person); var st = new Student("杨叶茂",19,"谢谢你的爱"); Student.method("getName",function(name){ return this.name; }); function Xw(name,value){ this.name = name; this.value = value; } Xw.inherits(Student); var xw = new Xw("xx","今天"); method...给当前function添加方法, inherits 单一继承,