const start = 3;
const end = 7;
const arr = Array.from({length: end - start + 1}, (_, i) => start + i);
console.log(arr); // [3, 4, 5, 6, 7]
js数组知道开始值和结束值,按顺序生成数字
最新推荐文章于 2024-08-22 14:32:34 发布
const start = 3;
const end = 7;
const arr = Array.from({length: end - start + 1}, (_, i) => start + i);
console.log(arr); // [3, 4, 5, 6, 7]