Native Web

There are many popular web app frameworks out there. But if you’re building a website, like a blog, a portfolio or a company site, where do you start these days?

The cost

Most people will go with one of these big frameworks. One they are comfortable with. But at what cost? It…

There are countless ways to iterate through JS objects and arrays. Here’s how to do it in the simplest way, with ES6 and beyond, for each purpose.

Objects

Keys and values

Loop through keys and values of an object.

Keys

Loop through keys of an object.

Values

Loop through values of an object.

Arrays

Loop through an array.

Return

If you want to return the items or the whole loop, you have to swap the forEach for a map. You can change it in any of the examples above, it will work as expected, and the result will be returned. A forEach will always return undefined.

Antoine Boulanger

Front-end Engineer. https://twitter.com/ABXlink

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store