Changing Elements of the Array in JS code example
Example 1: replace array element javascript
// Replace 1 array element at index with item
arr.splice(index,1,item);
Example 2: how to modify an array
let firstNumbers = [1, 2, 3];
let secondNumbers = [4, 5, 6];
let merged = firstNumbers.concat(secondNumbers);
console.log(merged); // [1, 2, 3, 4, 5, 6]