One Pager Cheat Sheet
- If you understand the differences between
blockingandnon-blockingoperations and how they relate toasynchronousoperations in web development, you can easily master working with these concepts. - In asynchronous execution, lines of code don't have to wait for each other to complete before being executed, as demonstrated using the
setTimeout()method. - Despite being a common anti-pattern in JavaScript,
Callback Hellcan be avoided by taking a closer look at our code to prevent the pyramid of doom from growing. - Promises
solve the problem of callback hellby providing a simpler syntax to chain asynchronous operations and better error handling. - You can create and use a
Promiseduring asynchronous programming to represent a state that can be eitherfulfilled,rejected, orpending. - The output of a
Promisecan be accessed using three methods:.then(),.catch()and.finally(),.then()being used to access a successful response and.catch()used to access an error response. - The two key methods for retrieving the value from a
Promiseare.then()and.catch(), which are used to get a value or an error respectively. - With async/await, we have a simpler approach to writing
Promises, allowing us to suspend the resolution of an asynchronous function explicitly, without needing to reason about multiple states. - The
async/awaitconcept allowspromisesto be suspended while the code outside the function continues to execute, finally providing the expected output once the promise is resolved. - By using the
awaitkeyword, execution of anasync functionis suspended until itsPromiseresults in aresolved value. - Asynchronous function
hello()does not contain anawaitkeyword, and the code willthrow a ReferenceErrorthat will be caught within thetry...catchblock, returning the value"Boo! You have a ReferenceError: abc is not defined", and logged out to the console through the.catch()method.


