ts/js 遍历 6到61
最常见的方法是使用 for 循环:
for (let i = 6; i <= 61; i++) {
console.log(i);
}
使用 Array.from() 方法:
const numbers = Array.from({ length: 56 }, (_, index) => index + 6);
for (const num of numbers) {
console.log(num);
}
使用数组的扩展符 ...
:
const numbers = [...Array(56).keys()].map(num => num + 6);
for (const num of numbers) {
console.log(num);
}