undefined vs spread

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
use spread
const isMobileView = true;
const test = () => {
  test: 1,
  test2: 2,
  ...(isMobileView && { ml: '-6px' }),
}
test();
ready
use undefined
const isMobileView = true;
const test = () => {
  test: 1,
  test2: 2,
  ml: isMobileView ? '-6px' : undefined,
}
test();
ready

Revisions

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