concept setTimeout() in category angular

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.
Most of the time, you use callbacks to run code after something happens. To get accustomed to the concept, you can use a function that’s built into JavaScript: setTimeout(). You may have already used it. In a nutshell, setTimeout() runs a callback function after the number of milliseconds that you declare. The basic construct for using it as follows:
We’re not going show you the source code of setTimeout() here, but a skeleton function that uses a callback. Declare a new function called setTimeout() that accepts the parameters callback and delay. The names aren’t important; they can be anything you want. The following code listing demonstrates this function. (Note that you won’t be able to run this function in a JavaScript console.)
Listing D.37. setTimeout skeleton
const setTimeout = (callback, delay) => { ... #1 ... callback(); #2 }; const requestB = setTimeout (() => { #3 console.log("Sally: Here's your $100"); #3 }, 1000); #3The callback parameter is expected to be a function, which can be invoked at a specific point in the setTimeout() function 1. In this case, you’re passing it a simple anonymous function 3 that will write a message to the console log. When the setTimeout() function deems it appropriate to do so, it invokes the callback, and the message is logged to the console. That’s not so difficult, is it?