To set default array values with JavaScript, we call the fill method.
For instance, we write
const a = Array(20).fill(0);
to create an empty array with 20 slots with Array.
Then we call fill to fill all the empty slots with 0.
Conclusion
To set default array values with JavaScript, we call the fill method.