callbacks

Callbacks in JavaScript refer to functions that are passed as arguments to other functions. These functions are executed at a later point in time, often in response to some event or after a certain asynchronous operation completes.

5+3=

empty

myFunction is an argument in other function (callback)


sum(5, 3, displayDOM);

function sum(x, y, myFunction) {
  let result = x + y;
  myFunction(result);
}

function displayConsole(output) {
  console.log(output);
}
function displayDOM(output) {
  document.getElementById("p1").innerHTML = output;
}