Working With ECMAScript 2019 Asynchronous Iteration Using “for-of”

How to use “for-of” loops in ECMAScript 2019

Mayank Gupta
TechnoFunnel

--

This article is focused on the concept of Asynchronous Iteration, which is available in ECMAScript 2019. The“for-of” loop is often used to iterate through the list of items inside a loop. We can now use the “for-of” loop in JavaScript to iterate through the list of Promises and provide the value received when the Promise is resolved.

Let's iterate through an array of numbers using the “for-of” loop:

The code above is a simple code that is iterating through the list of employeeSalaries. The code, in this case, is synchronously iterating over data. Each iterated value represent a data value.

Creating a Simple Promise Using “New Promise”

The code below gives a simple way to create a Promise in JavaScript:

--

--

Mayank Gupta
TechnoFunnel

9 Years of Experience with Front-end Technologies and MEAN Stack. Working on all Major UI Frameworks like React, Angular and Vue https://medium.com/technofunnel