- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Callback Functions
JavaScript Functions
JavaScript Callback Functions
A JavaScript callback function is a function passed to another function to be run later.
The receiving function decides when, and how many times, to call it.
Callbacks are how you tell JavaScript what to do once something finishes.
Example
Example
javascript
function greet(name, callback) {
console.log("Hello " + name);
callback();
}
greet("Ada", function () {
console.log("The greeting is done");
});