Test name | Executions per second |
---|---|
Array splice | 180545.1 Ops/sec |
ES6 Object Spread | 177.7 Ops/sec |
Object property assign | 97469616.0 Ops/sec |
var input = [];
for (var i = 0; i < 50000; i++) {
input.push({
id: i,
data: 'something'
})
}
const index = input.findIndex(val => val.id === 999);
input.splice(index, 1, {id: 999, data: 'somethingElse'});
input = {
input,
[999]: {id: 999, data: 'somethingElse'}
}
input[999] = {id: 999, data: 'somethingElse'}