How to generate sequence of numbers/chars in javascript?

前端 未结 18 1203
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 06:22

Is there a way to generate sequence of characters or numbers in javascript?

For example, I want to create array that contains eight 1s. I can do it with for loop, bu

18条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 06:44

    Another method, for those how are memory saving pedant:

    Array.apply(null, Array(3)).map(Function.prototype.call.bind(Number))
    

提交回复
热议问题