← Back to list

ES9 / ECMAScript2018

4. A Deep Dive into the Latest JavaScript Features — ES8

✅ open src 🚀 🚀 in Stackademic · 2024-02-15 06:11 · 381 claps · 1.3 min read paywalled
#es9 #js #javascript #web-develpoment #frontend
Open on Medium ↗
Wiki topics: 🌐 · Web Development

ES9 / ECMAScript2018

4. A Deep Dive into the Latest JavaScript Features — ES9

The JavaScript has been evolved a lot and one of the widely used language in the world. We are discussing about some core feature of ES9 / ECMAScript 2018 / ECMA2018, the iteration of the ECMAScript standard. Let’s talk about exciting features that can streamline your workflow and enhance your code.

In this article, we’ll delve into some of the key features introduced in ES9:

1. Asynchronous Iteration

Asyn iterator is powerful syntax to call async task in sync manner.

function fetcher(task,time) {
    return new Promise(function(res) {
        setTimeout(function() {
            res(`${task} Done`);
        }, time);
    })
}
const tasks = [1,2,3,4].map(d => {
    return fetcher(d, 1000* d);
});

(async () => {
    for await (const value of tasks) {
      console.log(value);
    }
})();

2. Promise.prototype.finally()

Promises now have a finally block, which will be executed after then or catch block. If we have any task that needs to be done in both then and catch block, we can now simply do that in finally block.

Best example: Hiding the loader.

task()
  .then(() => console.log("Promise Success"))
  .catch(() => console.log("Promise Failed"))
  .finally(() => console.log("Finally called"));
No matter promise is successful or failed,
finally will be called after then or catch block

case1: Promise success
// Output
// Promise Success
// Finally called

case2: Promise failed
// Output
// Promise Failed
// Finally called

Thank you for reading until the end. Before you go, Please consider clapping and following.

Javascript is weird, I like the weird things. Keep Smiling.

Useful Links:

**Read ES6Read ES7Read ES8Read ES9Read ES10Read ES11**

**Read ES12Read ES13Read ES14Read ES15**


메타데이터
post_id
fd2c2afd23a2
slug
es9-ecmascript-2018-fd2c2afd23a2
url
https://blog.stackademic.com/es9-ecmascript-2018-fd2c2afd23a2
canonical_url
https://blog.stackademic.com/es9-ecmascript-2018-fd2c2afd23a2
author_url
https://medium.com/@opensrc0
status
ok
fetched_at
2026-07-24 10:18:17