Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to Initialize and fill an array with the specified values in javascript

// how to Initialize and fill an array with the specified values in javascript
const initializeArrayWithValues = (n, val) =>
  Array.from({length: n}).fill(val);
  console.log(initializeArrayWithValues(4, 9)); // [ 9, 9, 9, 9 ]
 
PREVIOUS NEXT
Tagged: #Initialize #fill #array #values #javascript
ADD COMMENT
Topic
Name
6+9 =