What's the correct way of using the new ES5 array functions with ES6 generators? Do I have to explicitly convert the iterable into an array first, or is there a better way? For example:
function* range(low, high) {
var i = low;
while(i < high)
yield i++;
}
// Sum of numbers in range, doesn't work
console.log(range(0, 10).reduce((x,y) => x + y));
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…