How to loop an array with `for...in`?

const words = ['Hallo Welt', 'Nani?', '42']

// for-in loop
// output: 0, 1, 2
for(const key in words) {
  console.log(key)
}
Copy

September 3rd, 2019

# for...in - Looping an array

Add to bookmarks

for...in iterates over all enumerable properties of an object/array.

Tracking with Matomo to improve the UX. See Privacy Policy for more details.