What is a callback function in Javscript code example
Example 1: what are callback functions
funct printANumber(int number, funct callbackFunction) {
printout("The number you provided is: " + number);
}
funct printFinishMessage() {
printout("I have finished printing numbers.");
}
funct event() {
printANumber(6, printFinishMessage);
}
Example 2: js callback function
const add = (num1, num2) => num1 + num2;
const result = (num1, num2, cb) => {
return "result is:" + cb(num1, num2);
}
const res = result(12, 13, add);