-1:000000000000 | 0:60ec20956a3a |
---|---|
1 // Replacing Array.prototype.iterator with a generator affects for-of behavior. | |
2 | |
3 load(libdir + "iteration.js"); | |
4 | |
5 Array.prototype[std_iterator] = function* () { | |
6 for (var i = this.length; --i >= 0; ) | |
7 yield this[i]; | |
8 }; | |
9 | |
10 var s = ''; | |
11 for (var v of ['a', 'b', 'c', 'd']) | |
12 s += v; | |
13 assertEq(s, 'dcba'); |