If you call it directly in function a, then the callback function will be restricted to death. However, using functions as parameters has the following benefits: when you a(b), function b becomes a callback function, and you can also a(c) at this time, function c becomes a callback function. If you write functiona(){...;b();}, you lose the flexibility of variables.
The code copy is as follows:
function a(index,callback){
callback(index);
}
function b(index){
alert(index);
}
a(10000,b);