Skip to content
dreamcode
dreamcode
Map
Callbacks
Lesson 25 of 48
+15 XP on finish
JAVASCRIPT CLIMBSChapter 5 · JS Functions and Classes

Callback functions

A callback is a function passed into another function as an argument, which is then invoked inside the outer function to complete an action.

Worked example

How it reads

  • callback(cloud) calls the passed-in callback function
  • fetchCloud((name) => ...) passes an anonymous arrow function as callback
Cloud tip: Callbacks are essential for handling asynchronous operations like timer events and network requests.
index.js
JAVASCRIPT
real JavaScript, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Call process again with a callback that logs the result with a label, so the output includes result: 30 for process(15, ...).

Press Run to check your work.