I recently read a medium post where the author claimed that using is better than using While this might hold good in general cases, I think that generalisation was too broad and doesn’t do justice to either or For somebody who is new to Javascript making sense of these and decide which one to use can be a challenge. In this post I will list down things that I have learnt about these and how I decide when to use what. If you find anything interesting/useful in this article you can highlight them using our chrome extension async-await promises. async-await promises. https://bit.ly/highlights-extension I read somewhere that is syntactical sugar for using . So before getting to know or deciding on which approach to you use make sure that you have a better understanding of promises. I captured my learnings in the post . If you do not have time to go through the full article checkout the thumb rules that I follow. async-await promises async-await Understanding promises in Javascript Thumb Rules for using Promises Use promises whenever you are using asynchronous or blocking code. maps to and maps to for all practical purposes. resolve then reject catch Make sure to write both and methods for all the promises. .catch .then If something needs to be done in both the cases use .finally We only get one shot at mutating each promise. We can add multiple handlers to a single promise. The return type of all the methods in object whether they are static methods or prototype methods is again a Promise Promise In the order of the promises are maintained in values variable irrespective of which promise was first resolved. Promise.all Once you have wrapped your head around promises checkout It helps you to write code that is much more readable. When not used properly it has its downsides. You can read to checkout my learnings. If you do not have time to read the full article checkout my thumb rules. async await. Understanding async-await in Javascript Thumb Rules for async-await Here are a list of thumb rules I use to keep my head sane around using and async await functions returns a promise. async functions use an implicit Promise to return its result. Even if you don’t return a promise explicitly function makes sure that your code is passed through a promise. async async blocks the code execution within the function, of which it( ) is a part. await async await statement There can be multiple statements within a single function. await async When using make sure to use for error handling. async await try catch Be extra careful when using within loops and iterators. You might fall into the trap of writing sequentially executing code when it could have been easily done in parallel. await is always for a single promise. await Promise creation starts the execution of asynchronous functionality. only blocks the code execution within the function. It only makes sure that next line is executed when the resolves. So if an asynchronous activity has already started then will not have an effect on it. await async promise await So should I use promises or async-await The answer is that we will use both. Following are the thumb rules I use to decide when to use and when to use promises async await returns a The converse is also true. Every function that returns a can be considered as async function promise. promise async function is used for calling an and wait for it to or . await async function resolve reject blocks the execution of the code within the function in which it is located. await async If the output of is dependent on output of then I use . function2 function1 await If two functions can be run in parallel create two different and then run them in parallel. async functions To run promises in parallel create an array of promises and then use Promise.all(promisesArray) Every time you use remember that you are writing blocking code. Over the time we tend to neglect this. await Instead of creating huge with many in it, it is better to create smaller This way we will be aware of not writing too much of blocking code. async functions await asyncFunction() async functions. Another advantage of using smaller is that you force yourself to think what are the async functions that can be run in parallel. async functions If your code contains blocking code it is better to make it an function. By doing this you are making sure that somebody else can use your function asynchronously. async By making async functions out of blocking code, you are enabling the user who will call your function to decide on the level of asynhronicity he wants. Hope this helps you decide easily when to use promises and when to use and when to use promises async-await If you liked this article and would like to read similar articles, don’t forget to clap. Click and drag to clap more than once. 50 is the limit. Understanding Series This article is a part of my learning series, which I call . You can read more above it Understanding X in this link. Understanding Javascript _I have had a kind of “love and hate” relationship with JavaScript. But nevertheless JavaScript was always intriguing…_hackernoon.com Understanding promises in JavaScript _Async and Await are extensions of promises. So if you are not clear about the basics of promises please get comfortable…_hackernoon.com Understanding async-await in Javascript _I recently read a medium post where the author claimed that using async-await is better than using promises. While this…_hackernoon.com Should I use Promises or Async-Await _I think npm was one of the reasons for quick adoption of nodejs. As of writing this article there are close 7,00,000…_hackernoon.com Understanding npm in Nodejs Understanding Linux _Survival guide for those who are starting with Linux_hackernoon.com Linux Survival Guide for Beginners _Monitor all your server infrastructure_hackernoon.com Understanding Zabbix _Ubuntu Firewall for humans_hackernoon.com Understanding UFW _Monitoring services and starting them on boot_hackernoon.com Linux Systemctl Understanding React _React is all about keeping your front-end code modular and reusable. Components play a crucial role in making React…_hackernoon.com Understanding Functional Components Understanding Learning _The dictionary meaning of a rabbit hole is as follows._medium.com The Thing about Rabbit Holes Understanding Cryptocurrencies _Price is an important indicator. But it can also be misleading in many cases._blog.goodaudience.com Why comparing cryptocurrency prices is wrong _It has been more than an year since I started investing in cryptocurrencies. Following Warren Buffet’s advice of “Never…_hackernoon.com Beginner’s Guide to “Investing in Cryptocurrencies”