JSFiddle - React, Tailwind, and code Playground

by adouga

JavaScript

// Simple ES6 iterators

let idMaker = {
  [Symbol.iterator]() {
    let nextId = 8000;
    return {
      next() {
        return {
          value: nextId++,
          done: false
        };
      }
    };
  }
};

let it = idMaker[Symbol.iterator]();
console.log(it.next().value);
console.log(it.next().value);

for (let v of idMaker) {
  if (v > 8002) break;
  console.log(v);
}