call()
作用1:调用函数
var o = {
name: 'andy'
}
function fn(a, b) {
console.log(this);
console.log(a + b);
}
fn.call(o, 1, 2)
//输出对象o和3
作用2:实现继承
function Father(uname, age, sex) {
this.uname = uname
this.age = age
this.sex = sex
}
function Son(uname, age, sex) {
Father.call(this, uname, age, sex)
}
var son = new Son('昊昊', 25, '男')
console.log(son);