A brief look at async-await
I appreciate that the author is trying to illustrate something with an intentionally contrived example, but there is really no need for &quot;await&quot; in his &quot;chain()&quot; function:<p><pre><code>  function chain () {
    (function loop (i) {
        if (i &gt; 5) {
            &#x2F;&#x2F; set state to failed
            return;
        }

        check().then((result) =&gt; {
            if (!result) {
                return loop(i + 1);
            }

            &#x2F;&#x2F; set state to finished

        }).catch((error) =&gt; {
            &#x2F;&#x2F; set state to failed
        });
    }(0));
  }
</code></pre>
This is one of my pet peeve with proponents of promises actually. They come up with convoluted examples to argue against callbacks but it&#x27;s not the callbacks that are a problem, but the person writing the code.<p>Actually, I would argue that promises really made no sense until &quot;await&quot; became available because they introduce extra complexity and (small) performance penalty for no added benefit. Worse, it encourages less experienced developers to write code in a serial manner in situations where this is not necessary (a much bigger performance problem).<p>Even with &quot;await&quot;, the only time when it is really useful is when there have to be a several asynchronous operations that must happen serially because they use the result of the previous call. It depends on your field of work, of course, but in my experience these situations are really not that common.<p>Some time ago I wrote an article comparing performance of callbacks vs async&#x2F;await but it is also an example to show that callback code does not have to be more tedious to write:<p><a href="https:&#x2F;&#x2F;gir.me.uk&#x2F;posts&#x2F;node-8-async-await-performance-test.html" rel="nofollow">https:&#x2F;&#x2F;gir.me.uk&#x2F;posts&#x2F;node-8-async-await-performance-test....</a>