Junior JavaScript

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"));

More from JavaScript Tutorial

All questions for this course