Util
_.times
Invokes the iteratee n times, returning an array of the results of each invocation.
- // Lodash
- var result = _.times(10)
- console.log(result)
- // output: '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'
- // Native
- var result = Array.from({length: 10}, (_,x) => x)
- console.log(result)
- // output: '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'
- // Native
- var result = [...Array(10).keys()]
- console.log(result)
- // output: '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'
Browser Support for Array.from()
45.0 ✔ | ✔ | 32.0 ✔ | ✖ | ✔ | 9.0 ✔ |
当前内容版权归 you-dont-need 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 you-dont-need .