reduce vs object from entries

Benchmark created on


Setup

var data = { ...Array.from(Array(10000).keys()) };

Test runner

Ready to run.

Testing in
TestOps/sec
from entries
Object.fromEntries(Object.entries(data || {}).filter((d) => d[1]));
ready
reduce
  Object.entries(data).reduce(
    (acc, [key, value]) =>
      value === undefined ? acc : { ...acc, [key]: value },
    {}
  );
ready

Revisions

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