Promptles
Programming Basics

Callback

intermediate

Definition

A function you hand to another piece of code so it can run it later, when something happens, such as a click, a timer ending, or data arriving.

In the wild

`button.addEventListener("click", saveForm);` hands over `saveForm` as a callback. Nothing runs yet; the browser runs `saveForm` each time someone clicks.

More from Programming Basics