JavaScript中fn()和fn.call()之间的差异

JavaScript中fn()和fn.call()之间的差异,javascript,call,Javascript,Call,vs 这些方法之间的区别是什么?当您使用调用表单时,您明确了将调用函数的上下文 上下文将确定执行函数时此的值 在您的情况下,您正在传入this,这将是默认值,因此它是不可操作的。此外,您的tempFn函数不会调用this关键字,因此,如果您传入其他范围,也不会有任何问题。您阅读了吗? var tempFn = function(someText){ console.log(someText); } tempFn('siva'); // where I simply call the funct

vs


这些方法之间的区别是什么?

当您使用
调用
表单时,您明确了将调用函数的上下文

上下文将确定执行函数时此的值

在您的情况下,您正在传入
this
,这将是默认值,因此它是不可操作的。此外,您的
tempFn
函数不会调用
this
关键字,因此,如果您传入其他范围,也不会有任何问题。

您阅读了吗?
var tempFn = function(someText){
console.log(someText);
}

tempFn('siva');
// where I simply call the function with text 'siva'
tempFn.call(this,'siva');
// where I call the function using call method