How does the for...of loop handle objects by default?

  • It iterates over the properties.
  • It throws an error.
  • It iterates over the values.
  • It iterates over the keys.
The for...of loop in JavaScript is used for iterating over iterable objects like arrays, strings, maps, and sets. By default, it iterates over the values of an iterable, making it a convenient choice for iterating through the elements of an array or the characters of a string, for example. It doesn't work with plain objects (non-iterable) and would require additional steps or methods to iterate over object properties.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *