function Parent(){ this.name='zhangsan', this.id=2; this.getName = function(){ console.log(this.name) } } Parent.prototype={ getAge:function(){ console.log('age') } } function SubClass(){ this.name="lisi" } SubClass.prototype = new Parent(); var a = new Parent() var b = new SubClass() a.name='wangwu' a.getName() b.getAge() function inhir(o){ function F(){} F.prototype=o; return new F() } var c = inhir(Parent) console.log(c.name)