callback function in js example
Example 1: javascript callback
function greeting(name) {
alert('Hello ' + name);
}
function processUserInput(callback) {
var name = prompt('Please enter your name.');
callback(name);
}
processUserInput(greeting);
Example 2: callback function
function greeting(name) {
alert('Hello ' + name);
}
function processUserInput(callback) {
var name = prompt('Please enter your name.');
callback(name);
}
processUserInput(greeting);
Example 3: callback function
function createQuote(quote, callback){
var myQuote = "Like I always say, " + quote;
callback(myQuote);
}
function logQuote(quote){
console.log(quote);
}
createQuote("eat your vegetables!", logQuote);
Example 4: callback function
const ironMan = withGloves(withBoots(withArmor(withHelmet(TonyStark))));