Reputation:
I was looking for a Javascript equivalent to the constant string.ascii_lowercase 'abcdefghijklmnopqrstuvwxyz'
, but I haven't been able to find any.
It is no trouble to implement it myself. I found it useful in Python and now that I am working with Javascript I'd be happy to discover if something similar exists, and where to find it.
Upvotes: 1
Views: 1063
Reputation: 784
You can play with this by changing the number before 97. There many other ways, but this one is easy to remember:
String.fromCharCode(0+97) // 'a'
String.fromCharCode(1+97) // 'b'
.
.
.
String.fromCharCode(25+97) // 'z'
Upvotes: 1
Reputation: 6857
According to https://rosettacode.org/wiki/Generate_lower_case_ASCII_alphabet#JavaScript there's no easy constant like what you're looking for. The Python example on that page just uses string.ascii_lowercase
, so I'd assume if there was a better option, that one would have been used instead.
Upvotes: 0
Reputation: 1004
The short answer is no: such a constant does not appear to exist in Javascript. There are several ways of generating such a constant (i.e. How to generate an array of alphabet in jQuery?) or also just manually entering it, but as of right now there is no function which returns that shorthand in native JS.
Upvotes: 0