window
,但apply方法必須填上null
,call不須要填console.log(Math.max.call(1,5,7)); console.log(Math.max.apply(null,[1,5,7]));
function add(c,d){ return this.a + this.b + c + d; } var s = {a:1, b:2}; console.log(add.call(s,3,4)); // 1+2+3+4 = 10 console.log(add.apply(s,[5,6])); // 1+2+5+6 = 14