A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
/*
* meaningOfLife(): The callback method
*/
function meaningOfLife() {
log("The meaning of life is: 42");
}
/*
* printANumber(): A method which accepts a callback method as an argument
* takes a function reference to be executed when printANumber completes
*/
function printANumber(int number, function callbackFunction) {
print("The number you provided is: " + number);
}
/*
* event(): Driver method
*/
function event() {
printANumber(6, meaningOfLife);
}