function Person() {
this.sname = '测试' ;
this.age = 23 ;
this.sex = '男' ;
Person.prototype.say = function() {
return this.sname + ' , ' + this.age + ' , ' + this.sex ;
} ;
}
function Student() {
Student.prototype = new Person() ;
Student.prototype.constructor = Student ;
this.school = 'xxx 大学' ;
}
var stu = new Student() ;
alert(stu.__proto__) ;
alert(stu.sname) ; //undefined
为什么stu 没有继承Person 的属性呢? 只能访问自己的。 Student 的原型是[object Object], 请大家指点!谢谢大家!