title: What is the difference between JavaScript promises and async await?
body: <p>I have been using <a href="https://en.wikipedia.org/wiki/ECMAScript#6th_Edition_-_ECMAScript_2015" rel="noreferrer">ECMAScript&nbsp;6</a> and ECMAScript&nbsp;7 features already (thanks to Babel) in my applications - both mobile and web.</p>
  
  <p>The first step obviously was to ECMAScript&nbsp;6 levels. I learnt many async patterns, the promises (which are really promising), generators (not sure why the * symbol), etc.
  Out of these, promises suited my purpose pretty well. And I have been using them in my applications quite a lot.</p>
  
  <p>Here is an example/pseudocode of how I have implemented a basic promise-</p>
  
  <pre><code>var myPromise = new Promise(
      function (resolve,reject) {
        var x = MyDataStore(myObj);
        resolve(x);
      });
  
  myPromise.then(
    function (x) {
      init(x);
  });
  </code></pre>
  
  <p>As time passed, I came across ECMAScript&nbsp;7 features, and one of them being <code>ASYNC</code> and <code>AWAIT</code> keywords/functions. These in conjunction do great wonders. I have started to replace some of my promises with <code>async &amp; await</code>. They seem to add great value to programming style.</p>
  
  <p>Again, here is a pseudocode of how my async, await function looks like-</p>
  
  <pre><code>async function myAsyncFunction (myObj) {
      var x = new MyDataStore(myObj);
      return await x.init();
  }
  var returnVal = await myAsyncFunction(obj);
  </code></pre>
  
  <p>Keeping the syntax errors (if any) aside, both of them do the exact same thing is what I feel. I have almost been able to replace most of my promises with async,awaits.</p>
  
  <p>Why is async,await needed when promises do a similar job?</p>
  
  <p>Does async,await solve a bigger problem? Or was it just a different solution to callback hell?</p>
  
  <p>As I said earlier, I am able to use promises and async,await to solve the same problem. Is there anything specific that async await solved?</p>
  
  <p>Additional notes:</p>
  
  <p>I have been using async,awaits and promises in my React projects and Node.js modules extensively.
  React especially have been an early bird and adopted a lot of ECMAScript&nbsp;6 and ECMAScript&nbsp;7 features.</p>