A callback function is a function that is passed as an argument to another function and is executed later by that function.
Example:
function greet(name, callback) {
console.log("Hello " + name);
callback();
}
function message() {
console.log("Welcome to JavaScript!");
}
greet("Sathish", message);
Output:
Hello Sathish
Welcome to JavaScript!
Top comments (0)