Test name | Executions per second |
---|---|
Object.assign | 40.6 Ops/sec |
spread operator | 31.4 Ops/sec |
// Object.assign
function createObject(fillValue) {
return Object.fromEntries(new Array(1024*12).fill(fillValue).map((value, index) => {
return [fillValue + index, fillValue + index];
}));
}
const params = createObject('params');
const other = Object.assign(createObject('assign'), params);
// spread operator
function createObject(fillValue) {
return Object.fromEntries(new Array(1024*12).fill(fillValue).map((value, index) => {
return [fillValue + index, fillValue + index];
}));
}
const params = createObject('params');
const other = {createObject('spread'), params};