window.color='red';let o ={
color:'blue',};functionsayColor(){
console.log(this.color);}sayColor.call(this);//redsayColor.call(window);//redsayColor.call(o);//blue
apply和call真正强大的地方在于控制函数调用上下文即函数体内this值的能力
3.bind方法
window.color ='red';var o ={
color:'blue'}functionsayColor(){
console.log(this.color);}let objectSayColor =sayColor.bind(o);objectSayColor();//blue