A callback function is a function passed into another function as a argument. The function is invoked in the outer function to complete an action.
Let’s take a simple example of how to use the callback function:
`function callbackFunction(message) {
console.log("Hello " + message);
}
function outerFunction(callback) {
let message = prompt("Welcome to The Coding Dev");
callback(message);
}
outerFunction(callbackFunction); `
Top comments (1)
With this explanation of a callback function, I wonder why I should use it....