reduce vs map/join

Benchmark created on


Setup

const match = [
   { raw: "teckel" },
   { raw: "border" },
   { raw: "borzoi" },   
   { raw: "shiba" },      
]

Test runner

Ready to run.

Testing in
TestOps/sec
reduce / template string
const a = match.reduce((sum, value) => {
  sum = `${sum} ${value.raw}`.trim();
  return sum;
}, '');
ready
map / join
const a =  match.map(({ raw }) => raw).join(' ').trim();
ready

Revisions

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