range-like feature in Javascript

  • https://stackoverflow.com/a/10050831
console.log([...Array(5).keys()]);

for (const x of Array(5).keys()) {
    console.log(x);
}