When I start node v0.11.14 REPL with --harmony
option and try for-of loop, I get:
> for (var i of [3, 4, 5]) console.log(i);
TypeError: undefined is not a function
The same for sets. But it works fine with generators:
> function* Counter() { var n=3; while (n < 7) { yield n++; } }
> var c = new Counter();
> for (var i of c) console.log(i);
3
4
5
6
Though the first example from ecmascript wiki page is:
for (word of ["one", "two", "three"]) {
alert(word);
}
MDN page and Traceur docs contain the same example. I've failed to google "for-of in nodejs". Should it actually work in Node or am I missing something?