Object delete vs extract

Benchmark created on


Description

Checks what is the fastes way to remove a propery from an object.

Setup

const object = { prop1: 'a', prop2: 'b', prop3: 'c' };

Test runner

Ready to run.

Testing in
TestOps/sec
Delete prop
delete object['prop1'];

console.log(object);
ready
Extract prop
const {prop1, ...rest} = object;

console.log(rest);
ready
Iterate props
let result = {};
Object.keys(object).map(key => {
    if(key !== 'prop1') {
        result[key] = object[key];
    }
});

console.log(result);
ready

Revisions

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