« lllc | 首页 | 高伟 »

diguanianzhu

留言(1 条)

Javascript面向对象编程(二):构造函数的继承 留言:


引用Jun的发言:


取不到"动物" 值



原因在这里:
function Animal() {
this.species = "动物";
}

应该写为:
function Animal(){}
Animal.prototype.speies="动物";


你理解错了作者第五种方法的意思,第五种是是从第三种和第四种方法延伸而来的。