Returning object literal vs. Return object from function

Benchmark created on


Setup

const DEFAULT_PRESET = { preset: '7d' };

function getDefaultPreset() {
  return {
    preset: '7d',
  }
};

Test runner

Ready to run.

Testing in
TestOps/sec
log object literal
console.log(DEFAULT_PRESET)
ready
log function
console.log(getDefaultPreset())
ready

Revisions

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