Removing Object Properties: Destructuring Vs delete

Benchmark created on


Description

Test includes: Destructuring delete operator Test created by @Logos

Setup

let profile = {
  id: 1,
  disabled: true,
  size: 99,
  balance: 99,
  prices: [34, 56, 78],
  reward: 111,
  error: 'error'
};

Test runner

Ready to run.

Testing in
TestOps/sec
Destructuring
const updatedProfile = (
  ({error, ...restData}) => ({
    ...restData,
    id: 2,
    disabled: false,
    size: 88,
    balance: 88,
  })
)(profile);
ready
delete operator
const updatedProfile = {
  ...profile,
  id: 2,
  disabled: false,
  size: 88,
  balance: 88,
};

delete updatedProfile.error;
ready

Revisions

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