Demystifying Iterables by implementing a python like range function

Vivek Nayyar
5 min readMay 26, 2021
Photo by Rich Tervet on Unsplash

With ES6, we got introduced to the concept of Iterables. Iterating over an array using a for-in loop or a for-of loop is not new to us.

We have all done something like this at least once in our codebase:

But what if you would want to have that same functionality of iterating over something that is not an Array. How about an object?

In order to iterate over its values, we might have to use Object.values with a map.

--

--

Vivek Nayyar
Vivek Nayyar

Written by Vivek Nayyar

Engineering Manager and Board game enthusiast

Responses (1)