assign-vs-equals

Benchmark created on


Description

Direct Property Assignment vs. Object.assign for Multiple Properties

Setup


Test runner

Ready to run.

Testing in
TestOps/sec
Direct object assign
let myObject = {};
for (let i = 0; i < 50; i++) {
    myObject['prop' + i] = 'value' + i;
}
ready
Object.assign()
let myObject = {};
let props = {};
for (let i = 0; i < 50; i++) {
    props['prop' + i] = 'value' + i;
}
Object.assign(myObject, props);
ready

Revisions

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