Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Chrome 118
Windows
Desktop
one year ago
Test name Executions per second
Array.from 454.9 Ops/sec
spread 448.8 Ops/sec
push 444.7 Ops/sec
Script Preparation code:
AخA
 
var map = new Map(Array.from({ length: 5000 }, (_, i) => [String(i + 1), { id: String(i + 1) }]));
Tests:
  • Array.from

     
    const result = Array.from(map.values());
    console.log(result);
  • spread

     
    const result = [...map.values()];
    console.log(result);
  • push

     
    const result = [];
    for (const v of map.values()) {
      result.push(v);
    }
    console.log(result);