How to generate an array of alphabet in jQuery?

前端 未结 15 2224
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 15:57

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

15条回答
  •  隐瞒了意图╮
    2020-12-07 16:22

    new Array( 26 ).fill( 1 ).map( ( _, i ) => String.fromCharCode( 65 + i ) );
    

    Use 97 instead of 65 to get the lowercase letters.

提交回复
热议问题