Callback Explanation:
What is a Callback?
A callback is a function passed as an argument to another function
It allows you to pass a function that will be executed after the first function completes
Helps manage the order of execution in JavaScript
function doHomework(subject, callback) {
console.log(`Starting ${subject} homework`);
callback();
}
function finishHomework() {
console.log("Homework is done!");
}
doHomework("Math", finishHomework);
Top comments (0)