The ...
(spread operator) works by returning each value from index 0
to index length-1
:
As example:
[...'18'] // returns ['1', '8']
which would be the same as:
['18'[0], '18'[1]]
Now, to get an array from 1
to 18
, you can do this:
[...Array(19).keys()].slice(1)
Or this with map:
[...Array(18)].map(_=>i++,i=1)
Hope it helps.