function Student(name) {
People.call(this, name);
this.grade = '六年级';
this.study = function(type) {
console.log(this.name + '在学习:' + type);
}
}
(function() {
var Super = function(){};
Super.prototype = People.prototype;
Student.prototype = new Super();
})();
Student.prototype.constructor = Student;
Student.prototype.school = '实验小学';
Student.prototype.sleep = function() {
console.log(this.name + '在睡觉');
}
People.prototype.gender = 'male';
People.prototype.run = function(text) {
console.log(this.name + '在跑步');
}
var student = new Student('Jack');
console.log(student.grade);
console.log(student.study('英语'));
console.log(student.school);
console.log(student.sleep());
console.log(student.name);
console.log(student.walk());
console.log(student.age);
console.log(student.speak('你好'));
console.log(student.gender);
console.log(student.run());
console.log(student instanceof People);
console.log(student instanceof Student);
var another = new Student('Tomas');
another.likes.push('football');
student.likes.push('Basketball');
student.hates.push('Apple');
console.log(another.name);
console.log(another.walk());
console.log(student.likes);
console.log(another.likes);
console.log(student.hates);
console.log(another.hates);