How to fill array with value N from specific index in JavaScript

1 Answer

0 votes
const array = [1, 5, 7, 2, 1, 12, 6, 4];

array.fill(0, 3);

console.log(array);


  
    
    
/*
run:
    
[1, 5, 7, 0, 0, 0, 0, 0]
    
*/

 



answered Nov 30, 2020 by avibootz
...