Destructure vs overwrite

Benchmark created on


Description

Is it faster to destructure with default values or to overwrite those default values?

Setup

const foo = { a: 3, c: 4 };

Test runner

Ready to run.

Testing in
TestOps/sec
Destructure
const { a = 1, b = 2, ...rest } = foo;
console.log({ a, b, ...rest })
ready
Overwrite
console.log({ a: 1, b: 2, ...foo })
ready

Revisions

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