Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptcustom iterables Symbol.iteratorSingle-choice MCQ

You want an object whose `for...of` can be iterated MULTIPLE times independently. Which `Symbol.iterator` design achieves this?

const range = { from: 1, to: 3, [Symbol.iterator]() { let current = this.from; const last = this.to; return { next() { return current <= last ? { value: current++, done: false } : { value: undefined, done: true }; } }; } };