Object assign vs Object spread vs For Loop (v2)

Revision 2 of this benchmark created on


Setup

let a = { a: 1, b: 2, c: 3, d: 4, e: 5 };
let b = { f: "5", g: "4", h: "3", i: "2", m: "1" };

Test runner

Ready to run.

Testing in
TestOps/sec
Object.assign
Object.assign(a,b);
ready
Spread operator
a = {...a,...b};
ready
For
for (let keys = Object.keys(a), len = keys.length, i = 0; i < len; ++i) {
    a[keys[i]] = b[keys[i]];
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.