// 一组整数
Array.from(Array(10).keys())
[...Array(10).keys()]
Array.from({ length: 10 }, (_, i) => i)
// 一组偶数
Array.from({ length: 5000 }, (_, i) => i * 2 + 2)
Array.from({ length: 10000 }, (_, i) => i).filter(num => num % 2 === 0)
// 一组奇数
Array.from({ length: 5000 }, (_, i) => i * 2 + 1)
Array.from({ length: 10000 }, (_, i) => i).filter(num => num % 2 !== 0)
网友评论