I’m trying to run the code from here
function fib() {
var i = 0, j = 1;
while (true) {
yield i;
var t = i;
i = j;
j += t;
}
}
var g = fib();
for (var i = 0; i < 10; i++) {
console.log(g.next());
}
I cannot get it working in Node.js, Chrome or Firefox
It’s an EcmaScript.next feature that is being tested in newer versions of JavaScript interpreters.
Mozilla’s “Iterators and Generators” explains how to use them.
To see which browsers support which ES.next features, see kangax’s compatibility chart and browser specific reports. Although Chrome as a whole does not yet, jmar777 reports that V8 supports it (as of Aug 2013).