I am not sure if this is a bug from my application, but I have an array like this:
var arr = [{name: 'John'}, {name: 'Jane'}, {name: 'Smith'}, {name: 'George'}]; I am trying to replace {name: 'Jane'} with {name: 'Simon'} so, I am doing
arr.splice(1, 0, {name:'Simon'}) But Jane isn't removed. Just Simon is added to the list.
I thought the splice's first arg was where to place the new array, and 0 was to replace the existing array
var arr = [{ name: 'John' }, { name: 'Jane' }, { name: 'Smith' }, { name: 'George' }]; arr.splice(1, 0, { name: 'Simon' }) console.log(arr)
spliceto replace the entry at a given location.