Question from the Node.js test

Write a generator function in NodeJS that yields the numbers from 0 to infinity.

Expert

What will be the output of the console.log?
The following code implements the ES2015 specification.

function* idMaker() {
  var index = 0;
  while (true) {
    yield index++;
  }
}
var gen = idMaker();
console.log(gen.next().value);
Author: Jean-marie CléryStatus: PublishedQuestion passed 835 times
Edit
1
Community EvaluationsNo one has reviewed this question yet, be the first!