Replace the object at the specified location in the json array

var arr = [{id:1,pic:1},{id:2,pic:2},{id:3,pic:3}]

how to delete the second item of arr and insert a new object {id:4,pic:4}
results such as

arr = [{id:1,pic:1},{id:4,pic:4},{id:3,pic:3}]
Aug.12,2021

arr.splice (1,1, {id:4,pic:4});

Menu