Javascript Generator generate value in range
let numbers = {//from w w w.ja va2 s .c o m *range(start, end) { let current = start; while (current <= end) { yield current++; } } }; for (let num of numbers.range(1, 10)) { console.log(num); }