ES6 Generator Example

Demonstrates iterating an array of function yielding the result for each using a for loop and ES6 Generators.

Click to "Run Example 1" a simple generator.

  function* gen(){ 
    for(let f of funcs){
      yield f();
    }
  }

  function run() {
    var _results = [];
    for(let f of gen()){
      results.innerHTML += ('yield: ' + f + '
'); _results.push(f); } console.log(_results); }