- /*//类继承
- var father=function(){
- this.age=53;
- this.say=function(){
- console.log("name:"+this.name+",age:"+this.age);
- }
- };
- var child=function(){
- this.name="child";
- father.call(this);
- }
- var man=new child();
- man.say();
- console.log(man);
- */
- //原型继承
- var father = function() {}
- father.prototype.a = function() {
- console.log(11)
- };
- var child = function() {};
- child.prototype = new father();
- var man = new child();
- man.a();
- console.log(man);
来源: http://www.bubuko.com/infodetail-1869323.html