1. What is asynchronous code?
Code that executes some task and continues to run until a result is reached. Meanwhile other synchronous or asynchronous tasks are executed without waiting.
2. Describe what a callback function is
A callback function is a function that executes once the result of an asynchronous task is complete.
3. Why do we need asynchronous code at all? Can’t we just replace it with synchronous…
Because we may have an application that responds to events in real-time and we would like those responses to be updated in real time without causing our program to freeze as in the case of synchronous code we can only have a single piece of code running at a time.
4. What are Promises?
Promises represent the future value of an asynchronous task carried out from before. Rather than use a callback to return a result, we can retrieve a Promise object representing the actual data.
5. What does the then() function do?
It waits for an asynchronous task to finish before the next task/tasks within .then()
function is executed.