DEV Community

KISHAN RAMLAKHAN NISHAD
KISHAN RAMLAKHAN NISHAD

Posted on

callback

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);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)