Advertisement
728x90
A callback function is a function passed into another function as an argument. This function is invoked inside the outer function to complete an action.
Let's take a simple example of how to use callback function
javascript
1function callbackFunction(name) {
2
3console.log("Hello " + name);
4}
5
6function outerFunction(callback) {
7
8let name = prompt("Please enter your name.");
9
10callback(name);
11}
12
13outerFunction(callbackFunction);Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 56
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
55of476