Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

fill array with 0 javascript

const arrayWithZeros = Array(4).fill(0) // ES6!
console.log(arrayWithZeros) // [0, 0, 0, 0]
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #fill #array #javascript
ADD COMMENT
Topic
Name
4+4 =