创建指定长度的javascript的零数组

时间:2020-04-02 19:06:22

标签: javascript arrays

我正在寻找

的JS等效项

[0] * n用于创建长度为n的数组(python中的列表)。如何使用Javascript来做到这一点?

1 个答案:

答案 0 :(得分:0)

//12 is an axample, the length of the array
let arr = new Array(12).fill(0);
console.log(arr)