What is a callback function?
A function passed as an argument to another function to be executed later.
Example:
function greet(name, callback) {
console.log(`Hello, ${name}`);
callback();
greet("Sandeep", () => console.log("Callback executed"));
A function passed as an argument to another function to be executed later.
Example:
function greet(name, callback) {
console.log(`Hello, ${name}`);
callback();
greet("Sandeep", () => console.log("Callback executed"));