I want to construct the array ['a', 'b', 'c', 'd', ..., 'z']
in a clean way. The best I have found is
'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'.split(' ');
I wonder if there is a more "programmatic" approach.
Why not just a literal array?
var chars = [
'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'
];
I had to test, and this is a lot faster than splitting a string: jsperf.com/arraycreation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With