What is Callback

callback is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of action

Why we use
– we need to wait for a response from the server
– It helps us develop asynchronous JavaScript code and keeps us safe from problems and errors

The benefit of using a callback function is that you can wait for the result of a previous function call and then execute another function call.

function x (callBack){
      const p = "hello"
x(function(res){ console.log(res)})