cloning VS spreading

Benchmark created on


Setup

const STEP_VERIFY_OTP = {
  title: 'Verify your phone number',
  buttons: {
    submit: { content: 'Next' },
    cancel: { content: 'Cancel' },
    goBack: { content: 'Back' },
  },
  nextPath: 'ROUTE_MFA.ENABLE.success',
};
const otpCode = true;

Test runner

Ready to run.

Testing in
TestOps/sec
spread
  const stepConfig = {
    ...STEP_VERIFY_OTP,
    buttons: {
      ...STEP_VERIFY_OTP.buttons,
      submit: {
        ...STEP_VERIFY_OTP.buttons.submit,
        disabled: !otpCode,
      },
    },
  };
  console.log(JSON.stringify(stepConfig, null, 2))
ready
clone
const xxx = structuredClone(STEP_VERIFY_OTP);
xxx.buttons.submit.disabled = !otpCode;
console.log(JSON.stringify(xxx, null, 2))
ready

Revisions

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