Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object iteration vs Map iteration V2
(version: 0)
Comparing performance of:
Map - for of kv vs Map - forEach vs Object.entries() - for of kv vs Object.entries() - forEach vs Object - for in
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10, k: 11, l: 12, m: 13, n: 14, o: 15, p: 16, q: 17, r: 18, s: 19, t: 20, u: 21, v: 22, w: 23, x: 24, y: 25, z: 26 };
Tests:
Map - for of kv
var map = new Map(Object.entries(obj)); let total = 0; for (const [key, value] of map) { total += value; }
Map - forEach
var map = new Map(Object.entries(obj)); let total = 0; map.forEach(function(value, key) { total += value; });
Object.entries() - for of kv
let total = 0; for (const [key, value] of Object.entries(obj)) { total += value; }
Object.entries() - forEach
let total = 0; Object.entries(obj).forEach(function(value, key) { total += value; });
Object - for in
let total = 0; for (const key in obj) { total += obj[key]; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Map - for of kv
Map - forEach
Object.entries() - for of kv
Object.entries() - forEach
Object - for in
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Object.values Array.prototype.map vs Lodash.map
Object.entries Array.prototype.map vs Lodash.map
Object iteration methods with maps, foreach, different access types, no mutation
Object.values vs for in loop vs for loop
Object.values vs for in loop vs for loop v2
Comments
Confirm delete:
Do you really want to delete benchmark?