call和applay

apply同call其实是一样的只不过apply是将参数封锁到数组里

函数名.call(借用人,参数1,参数2,参数3...);


函数名.apply(借用人,[参数1,参数2,参数3]);

var text1 = document.getElementById("text1");
var text2 = document.getElementById("text2");
function t(){
this.style.backgroundColor = 'gray';
}
t.call(text2);//text2借用t函数

原文地址:https://www.cnblogs.com/niuniuniu/p/6396460.html