-2

let array1 = Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); how to make like this array with shortest way ? is it possible to make shorter way ? thank you for your answers.

1 Answers1

3

You can use the .fill() method:

let array1 = new Array(16).fill(0);

As its name suggests, it fills the array with some desired value.

Pointy
  • 405,095
  • 59
  • 585
  • 614