Answers for "How to create an array containing 1...N"

0

How to create an array containing 1...N

Array.from({length: 10}, (_, i) => i + 1)
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Posted by: Guest on December-22-2021
0

How to create an array containing 1...N

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

Array.from(Array(10).keys())
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

[...Array(10).keys()]
//=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Posted by: Guest on March-22-2022

Code answers related to "How to create an array containing 1...N"

Code answers related to "Javascript"

Browse Popular Code Answers by Language