- Array.from
let re = Array.from(new Array(10), (_, idx) => idx + 1);
console.log(re);
- new Array
let arr = new Array(10).fill().map((item, index) => index + 1);
console.log(arr.length, arr);
- Array
[...Array(10)].map((_, i) => i + 1)
let re = Array.from(new Array(10), (_, idx) => idx + 1);
console.log(re);
let arr = new Array(10).fill().map((item, index) => index + 1);
console.log(arr.length, arr);
[...Array(10)].map((_, i) => i + 1)