Suppose A is an asynchronous function, A has a parameter A and a callback function (b), where the callback function has a return value b,a function is called a (a,function (b)), and C is a wrapper function in which the asynchronous function A is called. Then, when you want to call the C function externally, get the result B value of the A function executed asynchronously, you can add a callback function named C to C and call the method C (a,c). The above formula pseudo-code can be represented if:
function C (a,c) {
A (A,function (b) {
C (b);
});
}
function C (b) {
Console.log (b);
}
Code Description:
1.functionC (A,C): C is a callback function name for the C function.
2.A (A,function (b) {}): A is an asynchronous function where a is its argument and function (b) {} is an unnamed callback function.
3.C (b): Call C's callback function name and pass the B return value to the C function.
4.function C (b): handles the return result of the asynchronous call function.
node. JS Asynchronous callback