Callback Function
Passing a function to another function or passing a function inside another function is known as a Callback Function. In other words, a callback is an already-defined function that is passed as an argument to the other code
Syntax:
function geekOne(z) { alert(z); }
function geekTwo(a, callback) {
callback(a);
}
prevfn(2, newfn);
Above is an example of a callback variable in a JavaScript function. “geekOne” accepts an argument and generates an alert with z as the argument. “geekTwo” accepts an argument and a function. “geekTwo” moves the argument it accepted to the function to pass it to. “geekOne” is the callback function in this case.