-1

I was looking for the JS equivalent of

[0]*n for creating an array(lists in python) of n length. How do I do that using the Javascript?

pasha
  • 406
  • 1
  • 4
  • 17
  • `Array(n).fill(0)` – VLAZ Apr 02 '20 at 19:08
  • 1
    Does this answer your question? [Most efficient way to create a zero filled JavaScript array?](https://stackoverflow.com/questions/1295584/most-efficient-way-to-create-a-zero-filled-javascript-array) – VLAZ Apr 02 '20 at 19:08

1 Answers1

0

//12 is an axample, the length of the array
let arr = new Array(12).fill(0);
console.log(arr)
Mechanic
  • 5,015
  • 4
  • 15
  • 38
  • Hey is there something I can do to make it change the 0 into a float? fill seems to be truncating – pasha Apr 03 '20 at 03:18