问题描述
到目前为止,我认为调用"和调用"功能是同一回事.但是,在YouTube教程中,它表示要通过调用功能 来调用它.我最初的想法是措辞是一个错误,但是在W3Schools的页面中,它说:
Up to this point, I thought "calling" and "invoking" a function meant the same thing. However, in a YouTube tutorial it said to invoke a function by calling it. My first thought was that the wording was a mistake, but on W3Schools' page on Function Invocation, it says:
好的,所以有所不同.什么事?
Okay, so there's a difference. What is it?
推荐答案
您的参考文本:
现在让我改一下:
因此,当我执行 fn()
时,它被直接调用,而当我执行 fn.call()
时,它被间接调用,但是在两种情况下,函数正在被调用.否则,我在这里看不到任何区别,我也可以说我可以通过多种方式调用函数,例如:
So, when I do fn()
, it's invoked directly and when I do it like fn.call()
, it's invoked indirectly but in both cases, the function is being invoked. Otherwise, I see no difference here and I can also say that I can call a function in many ways, for example:
fn(); // I'm calling it
fn.call(); // I'm calling it
fn.apply(); // I'm calling it
因此,区别是语义上的,但两者都是可互换的,IMO.顺便说一句,我在上面的问题下写了一条评论,我想放在这里,它是:
So, the difference is semantic but both are interchangeable, IMO. BTW, I wrote a comment above, under the question and I would like to put it here, which is:
这篇关于调用与调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!