and pass in a callback function code example
Example 1: javascript pass function as parameter
//passing a function as param and calling that function
function goToWork(myCallBackFunction) {
//do some work here
myCallBackFunction();
}
function refreshPage() {
alert("I should be refreshing the page");
}
goToWork(refreshPage);
Example 2: javascript callback function
const message = function() {
console.log("This message is shown after 3 seconds");
}
setTimeout(message, 3000);