什么是回调? (What are callbacks?)
Quite literally, callbacks can be understood as calling something back. In programming, we use a call to imply that we're calling a function, so what's callback? To put simply, it's one function calling another. Quite literally, callbacks can be understood as calling something back. In programming, we use a call to imply that we're calling a function, so what's callback? To put simply, it's one function calling another.
从字面上看, 回调可以理解为回调某些东西。 在编程中,我们使用一个调用来暗示我们正在调用一个函数,那么回调是什么呢? 简而言之,它是一个函数调用另一个函数。 从字面上看,回调可以理解为回调某些东西。 在编程中,我们使用一个调用来暗示我们正在调用一个函数,那么回调是什么呢? 简而言之, 它是一个调用另一个函数的函数 。
Now let's see the more accurate definition of a callback with an example.
现在,让我们看一个示例的更准确的回调定义。
A callback is a function that is passed to another function as a parameter and then invoked by other functions. The function to which the callback is passed is often referred to as a higher-order function. Conversely, Higher-Order Functions operate on other functions by either taking them as arguments or by returning them.
回调是一个函数,将其作为参数传递给另一个函数,然后由其他函数调用 。 回调传递给的函数通常称为高阶函数。 相反,高阶函数通过将其他函数作为参数或通过将其返回来对其他函数进行操作。
function higherOrder(callbackfn) {
console.log('inv