Callback function is a function which is calling other function
For example:
1. console.log('Start')
2. setTimeout(() => {console.log('3 sec Timer'), 3000)}
3. console.log('Stop')
As other programming languages here to the code start with main() function, then when it comes to the first line of the code, it would be executed, so the output would be: Start
Then when it comes to the second line, setTimeout is a callback function as it is a function which has to be executed first, on the completion of it, it would call the second function i.e. console.log('3 sec timer')
but here the o/p 3 sec timer will not come as Node.js does asynchronous programming, the callback function is stored in the place named as callback queue till the main() function gets completed
So it would move to line three now, so the output now would be:
Start
Stop
Once the main function execution gets completed, the event loop in Node.js would say to execute the callback function which is stored in the callback Queue.
so the final output would be:
Start
Stop
3 Sec Timer