本以为下面这行代码就可以实现:
(new Array(5)).map((item, idx) => idx)
但是:
至于为什么会是这样,我没有仔细追究,如果有知道的朋友欢迎指出。
正确方法:
// 第一种方法
Array.apply(null, {length: 10}).map((item, idx) => idx)
// 第二种方法
[...new Array(10)].map((item, idx) => idx)
// 第三种方法
[...new Array(10).keys()]