Answers for "js generator"

2

js generator

function* fibonacci() {
  var a = yield 1;
  yield a * 2;
}

var it = fibonacci();
console.log(it);          // "Generator {  }"
console.log(it.next());   // 1
console.log(it.send(10)); // 20
console.log(it.close());  // undefined
console.log(it.next());   // throws StopIteration (as the generator is now closed)
Posted by: Guest on April-23-2020
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