function * fib() { var fn1 = 1, fn = 0; while ( true ) { var ret = fn; fn = fn1; fn1 = fn + ret; yield ret; } // while } f1 = fib(); f2 = fib(); for ( var i = fib.length; i < 10; i += 1 ) { console.log( f1.next().value, f2.next().value ); } // Local Variables: // // tab-width: 4 // // compile-command: "node Fib.js" // // End: //