How to Get the Alphabet as Array in Javascript


If you need to get an array of alphabetical letters in Javascript then you can use one of the following:

Option 1 – Explicitly define the array first

const alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];

Option 2 – Split a string of alphabetical characters

const alphabetArray = "abcdefghijklmnopqrstuvwxyz".split("");

Option 3 – Split a string and UpperCase characters

const alphabetArrayUp = toUpperCase("abcdefghijklmnopqrstuvwxyz").split("");