1. What is the difference between synchronous and asynchronous functions?
Synchronous functions are executed in a sequence, each statement waits for the previous to finish before executing. Asynchronous functions don’t have to wait, they can be startet and put aside – the program can continue to run. That keeps a site or app responsive, reducing waiting time for the user.
2. What is callback hell?
Complex operation in a Javascript code, where the program tries to execute multiple asynchronous operations one after the other. That will produce several callbacks in various levels and sublevels which will easily end up in error prone, hard to read and hard to maintain code. For example when you have a callback that is nested in another callback which is nested in yet another callback…
3. Which technique can help us solve callback hell?
Promises. A ’promise’ is an object that will return a value in future. Because of this “in future” thing, Promises are well suited for asynchronous JavaScript operations. What also helps is to write comments, to split function s into smaller functions…