Answers for "function generator js"

4

javascript generator function

function* idMaker() {
  var index = 0;
  while (true)
    yield index++;
}

var gen = idMaker();

console.log(gen.next().value); // 0
console.log(gen.next().value); // 1
console.log(gen.next().value); // 2
console.log(gen.next().value); // 3
// ...
Posted by: Guest on June-06-2020
1

generator function javascript

function* expandSpan(xStart, xLen, yStart, yLen) {
    const xEnd = xStart + xLen;
    const yEnd = yStart + yLen;
    for (let x = xStart; x < xEnd; ++x) {
         for (let y = yStart; y < yEnd; ++y) {
            yield {x, y};
        }
    }
} 


//this is code from my mario game I dont think this code is functional
Posted by: Guest on June-18-2021
0

function generator js

function* name([param[, param[, ... param]]]) {
   statements
}
Posted by: Guest on July-27-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language