How to remove elements from array and add new elements in their place with JavaScript

1 Answer

0 votes
const arr = [4, 6, 8, 1, 2, 3, 0, 9];

arr.splice(1, 2, 100, 200, 300);

console.log(arr);
 
 
 
/*
run:
      
[4, 100, 200, 300, 1, 2, 3, 0, 9] 
         
*/

 



answered Aug 30, 2020 by avibootz
...