assign-vs-equals (v2)

Revision 2 of this 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
Object.assign() single
let myObject = {};
for (let i = 0; i < 50; i++) {
    Object.assign(myObject, {
        ['prop' + i]: 'value' + i
    });
}
ready

Revisions

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