Object assignment performance

Benchmark created on


Preparation HTML

<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>

Setup

const a = { a: 'oh', b: 'my', d: '' };
const b = { c: 'goddess', d: undefined };

const merge = (dest, properties) => {
	Object.keys(properties).forEach(key => {
        if (properties[key] !== undefined) {
            dest[key] = properties[key];
        }
    });
}

Test runner

Ready to run.

Testing in
TestOps/sec
Object.assign
const c = Object.assign(a, b);
ready
Lodash merge
const c = _.merge(a, b);
ready
Custom merge
const c = merge(a, b);
ready

Revisions

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