🎉 October Learning Month — learn a new software term every day!
An interactive flashcard trainer for software engineering terms.

Callback

In plain terms

A function passed to another function to be called later.

Going deeper

Callbacks let code run after an operation finishes, the basis of asynchronous programming before promises. Deeply nested callbacks can become hard to read ('callback hell').

Under the hood

Inversion of control where you hand off a function to be invoked later; deeply nested callbacks ('callback hell') motivated promises and async/await.

Examples

setTimeout(fn), event handlers, array.map(fn), Node.js fs.readFile callbacks.

Think of it like...

Like leaving your number with a shop: 'call me back when my order is ready,' so you don't stand waiting at the counter.

Feedback & Bug Report