Here in the example, the callback is a function. Therefore, you must pass an argument to the function.
You can do this in two ways:
var some_fun = function(some_str) {
alert(some_str);
}
var sayHi = function(callback) {
callback("hi");
}
sayHi(some_fun)
or you can pass a function when you call it:
var sayHi = function(callback) {
callback("hi");
}
sayHi(function(some_str){
alert(some_str);
});
source
share