Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Chrome 124
Windows
Desktop
9 months ago
Test name Executions per second
reduce 2183.1 Ops/sec
map + fromEntries 968.5 Ops/sec
reduce spread 69.6 Ops/sec
Script Preparation code:
AخA
 
var data = { ...Array.from(Array(10000).keys()) };
Tests:
  • reduce

     
    Object.entries(data).reduce((acc, [k, v]) => {
      acc[k] = v.toString();
      return acc;
    }, {});
  • map + fromEntries

     
    Object.fromEntries(Object.entries(data).map(([k, v]) => ([k, v.toString()])));
  • reduce spread

     
    Object.entries(data).reduce((acc, [k, v]) => ({
      ...acc,
      [k]: v.toString(),
    }), {});