function after that takes the number of times the callback can be executed as the first parameter and the callback function as the second paramete code example

Example 1: call back function in javascript

function greeting(name) {
  alert('Hello ' + name);
}

function processUserInput(callback) {
  var name = prompt('Please enter your name.');
  callback(name);
}

processUserInput(greeting);

Example 2: javascript callback function

const message = function() {  
    console.log("This message is shown after 3 seconds");
}
 
setTimeout(message, 3000);

Tags:

Misc Example