1function range(start, end) {
2 return Array(end - start + 1).fill().map((_, idx) => start + idx)
3}
4var result = range(9, 18); // [9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
5console.log(result);
1for (i of range(1, 5)) {
2 console.log(i);
3}
4/* Output
5 * 1 2 3 4 5 */
6
7[...range(1, 5)] // [1, 2, 3, 4, 5]
8