Mid JavaScript

What are callbacks?

A callback is a function passed as an argument to another function to be executed after

some operation completes.

Example:

function fetchData(callback) {

setTimeout(() => {

callback("Data received!");

}, 1000);

Follow me on LinkedIn:

fetchData(console.log);

More from JavaScript Tutorial

All questions for this course