function Human(name){ //function Human(){}就是类 this.name = name } Human.prototype.run = function(){ console.log("我叫"+this.name+",我在跑") return undefined } function Man(name){ Human.call(this, name) //Man继承Human this.gender = '男' }
Man.prototype.__proto__=Human.prototype //IE不支持 var f = function(){} f.prototype = Human.prototype //只要Human的prototype Man.prototype = new f() //IE支持,f就是去掉‘this.name=name’的Human
Comments