1. What is the difference between synchronous and asynchronous functions?
Synchronous functions in JS are functions that execute one after the other. Hence, each successive function will not execute unless the one before it has finished execution.
Asynchronous functions , such as callbacks, typically use the event loop, and can start execution but donât lock up the browser until theyâre finished. In contrast, other code below the functions continues executing until the task being done by the asynchronous function finishes execution.
2. What is callback hell?
Callback hell is when multiple asynchronous functions become nested, one within the other, each designed to be executed after a certain asynchronous task (file read being complete, ajax request completion, etc.) has finished.
3. Which technique can help us solve callback hell?
JS promises and the new async, await key words are one two ways to avoid callback hell.