js 1到31的数组,code和text展示
时间: 2023-12-10 15:40:41 浏览: 130
javascript数组
代码:
```javascript
const arr = Array.from({length: 31}, (_, i) => i + 1);
console.log(arr);
```
输出:
```javascript
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
```
文本展示:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
阅读全文