ES6 - generate an array of numbers

前端 未结 6 711
我寻月下人不归
我寻月下人不归 2021-01-31 08:03

Having googled for it I found two solutions:

6条回答
  •  隐瞒了意图╮
    2021-01-31 08:46

    Here is a simple solution that works in codepen:

    Array.from(Array(10).keys())
    

    To be clear, Array.from() and Array.keys() require an ES6 polyfill in order to work in all browsers.

提交回复
热议问题