range with array code example
Example 1: generate array range
for (i of range(1, 5)) {
console.log(i);
}
/* Output
* 1 2 3 4 5 */
[...range(1, 5)] // [1, 2, 3, 4, 5]
Example 2: array of range of numbers
k=5
console.log(
Array.from({length:5},(v,k)=>k+1)
)