function Person(name, age, sex){
this.name = name;
this.age = age;
this.sex = sex;
}
function Student(name, age, sex, tel, grade) {
//var this = {}
Person.call(this, name, age, sex);
this.tel = tel;
this.grade = grade;
}
var student = new Student('sunny', 123, 'male', 139, 2019);
call 和 apply 的区别
都是改变 this 指向的,但是传参列表不同
call 需要把实参按照形参的个数传进去
apply 需要传一个 arguments (把参数放到一个数组中)