What is the difference between `for…in` and `for…of` loops?

JavaScript Developer Hard

JavaScript Developer — Hard

What is the difference between `for…in` and `for…of` loops?

Key points

  • `for...in` iterates over property keys, including inherited ones
  • `for...of` iterates over values of iterables using the iterator protocol
  • `for...in` should not be used on arrays for value iteration

Ready to go further?

Related questions