Sitemap
Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

ES9 / ECMAScript2018

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

2 min readFeb 15, 2024

--

Press enter or click to view image in full size

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.

--

--

✅ open src 🚀 🚀
✅ open src 🚀 🚀

Written by ✅ open src 🚀 🚀

1. Open source contributor, Architect at Jio Platform Ltd. and The Author of fe-pilot. https://github.com/opensrc0/fe-pilot/

Stackademic
Stackademic

Published in Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.