1. es6之前没有extents继承,我们可以使用构造函数+原型对象模拟现实继承。
call()方法的作用:1.调用这个函数,2.修改函数运行时的this指向。
function motto1() {
console.log("迅速做完简单的部分,把节省的时间放在困难部分的处理上!!");
console.log(this);
}
function motto2() {
console.log("每一时刻的现状都是过去某一时刻或某些时刻的结果,而每一时刻的现状都是未来某一时刻或某些时刻的原因!!!");
}
motto1.call(motto2);//调用motto1,并把函数中的this指向改为motto2;
motto1函数中的this指向被改成了motto2;
2. call()方法的应用:借用构造函数继承父类的属性。