snippet Sunday 2 November 2025

Author
Eric Wallen
var myArray = [...Array(101).keys()]There are many ways to do this but the shortest most concise way I have found is with the code below. It cleverly uses the Array constructors keys() method inside a spread operator with an array [] wrapping everything. The result of that gets stored into the myArray variable.