js array 1 to 10, 0 to 9

kinghong97·2022년 5월 24일
0
Array.from(Array(10).keys())
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Array.from({length: 10}, (_, i) => i + 1)
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Array.from({length: 10}, (_, i) => i + 11)
//=> [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

0개의 댓글