Test name | Executions per second |
---|---|
boring | 46994048.0 Ops/sec |
spread | 6300799.5 Ops/sec |
Object.assign | 9192079.0 Ops/sec |
const obj = {
hello: "world"
};
if (Math.random()>.5) {
obj.foo = "bar";
}
const obj = {
hello: "world",
Math.random()>.5 && { foo: "bar" }
};
const obj = Object.assign({
hello: "world"
}, Math.random()>.5 && {
foo: "bar"
});