Callback Function

A callback function is a function passed into another function as an argument.
This can then be invoked inside the outer function to complete some kind of routine or action.

Synchronous callback

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

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


function ask(question, yes, no) { 
  if (confirm(question)) yes()
  else no();

  "Do you agree?",
  function() { alert("You agreed."); },
  function() { alert("You canceled the execution."); }

Asynchronous Callback

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext