I'm pretty sure there's not a better way to do this but figured it couldn't hurt to ask.
I'm tired of typing out
Cool languages have
What can we come up with with JS that's as short as possible??
is longer than just the alphabet - but guarantees I don't screw up somewhere.
I'm hoping there's a nasty bit-shifty way to produce a-z in less than 50 characters.
I messed around with
but it was always way longer by the time I joined then split the array(26) to be useable
Edit: I've gotten it down to
`[...Array(26)].map((q,w)=>String.fromCharCode(w+97))` is 52 bytes and add another 7 for the `.join\`\``
@dev-null a='';i=97;[...Array(26)].map(b=>a+=String.fromCharCode(i++)) is 60 but takes care of the join how are you doing join in 7 without getting commas in the result?
Alternative to String.fromCharCode
... if you are happy with a lowercase only alphabet.
for(i=9,a='';++i<36;)a+=i.toString(36) // 38, cannot be used in an expression
[...Array(26)].map(_=>(++i).toString(36),i=9).join`` // 52 directly returnig the string desired
[...Array(26)].map(_=>a+=(++i).toString(36),a='',i=9) // 53 assign to a variable
(i=9,[for(_ of Array(26))(++i).toString(36)].join``) // 52 ES7 direct return
i=9,a='',[for(_ of Array(26))a+=(++i).toString(36)] // 51 ES7 assign to a variable
Oh dang, that is clever. So it's starting with 10, converting to base 36 and printing it? so a-z!
Are those a='' and i=9 arguments of map function call? Checked Array.prototype.map() on mdn and it doesn't look like map support such arguments..
@JaySomedon see also this answer and related comments https://codegolf.stackexchange.com/a/2684/21348
@edc65 One more thing, are these same: `var a = [...Array(26)]`, `var b = Array(26)`, `var c = new Array(26)`? In console, `a` prints `[undefined, undefined..]` and b and c print `[empty slots...]` but all `a``b``c` evaluate to `undefined`. But only calling `map` on `[...Array(26)]` gives me alphabets, calling on the other two give me nothing, wonder why. Also on mdn, I can't find any example about `Array(n)`, so I wonder how `Array(n)` and `new Array(n)` are related with each other?