Iterate Map entries
Date tested:
4 years ago
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
Test name
Executions per second
For Entries
10142030.0 Ops/sec
Foreach
6000106.0 Ops/sec
Benchmark definition (click to collapse):
Script Preparation code:
var map = new Map(); for (var i = 0; i < 10000; i++) { map[Math.random()] = Math.random(); }
Tests:
For Entries
for (var [key, value] of map.entries()) { key value }
Foreach
map.forEach(function(value, key) { key value }, map)
Open this result on MeasureThat.net