Question · JavaScript and TypeScript course · Module 5: Advanced JavaScript

Symbol.iterator and for...of

What must an object implement to be usable in a for...of loop?

Answer options

  • A forEach() method
  • A [Symbol.iterator]() method that returns an iterator
  • A length property and numeric indices
  • A toString() method

You can check the correct answer by solving this task in the CodeWorlds game.