Async Timer

We spent a lot of time at Flatiron learning about ES6 features (arrow functions, spread operators, etc.). Today I decided to explore features from subsequent ECMAScript versions and built this app!


ES6 and ECMAScript don’t sound familiar to you, then check out this great overview on Medium. This article summarizes a lot of the major new features from ES6 through ES9

Async Functions

I was drawn to the Async Functions feature from ES9. I’ve seen async/await functions before, but until now I haven’t used this syntax.

MDN provides a great summary of the ES9 async function feature:

The async function declaration defines an asynchronous function, which returns an AsyncFunction object. An asynchronous function is a function which operates asynchronously via the event loop, using an implicit Promise to return its result. But the syntax and structure of your code using async functions is much more like using standard synchronous functions.

Async Timer

Per usual, MDN provides a concise example demonstrating how to use the async syntax. I decided to modify this example into an async timer.

Here is a codepen to my example. I had a lot of fun making this timer. I really liked seeing how powerful an async function can be a simple program.