Async & Await
The await keyword allows you to pause the execution of an async function until the asynchronous code is done executing. It’s like a school bus stop sign telling the program to wait until all the kids pass by. Now, the keyword can only be used in an async function, but it makes dealing with async code easier and increase code cleanliness. Much better than using callbacks. Here’s an example that shows the difference; imagine these functions as server requests.
As you can see the code is more clear and the await keyword pauses the execution until the data is received.In the former, you have to declare a callback just to log that information from the server. Now, imagine if you wanted to get a group of pictures in order; you’d have to write a callback within a callback within a callback. With async and await, you can get them all in the form of an array using Promise.all. So, this is an awesome improvement over the former, so enjoy the shiny new toys.