In Ruby I can do (\'a\'..\'z\').to_a
and to get [\'a\', \'b\', \'c\', \'d\', ... \'z\']
.
Do jQuery or Javascript provide a similar construc
Using JavaScript's Array.from syntax allows you to create an array and perform a mapping function on each of the array elements. Create a new array of length 26 and on each element set the value equal to the string obtained from the char code of the index of the current element plus the ascii magic number.
const alphabet = Array.from(Array(26), (e, i) => String.fromCharCode(i + 97));
Again, 97 may be interchanged with 65 for an uppercase alphabet.
The array may also be initialized with values using the object's keys method rather than utilising the index of the map
const alphabet = Array.from(Array(26).keys(), i => String.fromCharCode(i + 97));