Having googled for it I found two solutions:
All of the other answers here create a temporary intermediate array, which isn't necessary.
Array.from({ length: 10 }, (_, i) => i)
This is essentially a map function where you map from array index to whatever you'd like, for any number of elements.