Simple solution:
简单的解决方案:
Array(12).fill(0)
fill()
is a new method introduced in ES6.
fill()
是ES6中引入的新方法。
翻译自: https://flaviocopes.com/how-to-initialize-array-with-values/
Simple solution:
简单的解决方案:
Array(12).fill(0)
fill()
is a new method introduced in ES6.
fill()
是ES6中引入的新方法。
翻译自: https://flaviocopes.com/how-to-initialize-array-with-values/