Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.entries VS Object.keys VS Object.keys with extra array VS Object.entries without array 103
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Object.entries
487343.2 Ops/sec
Object.keys
820517.3 Ops/sec
Object.entries without array
512904.2 Ops/sec
For in
1445939.8 Ops/sec
For of keys
834820.0 Ops/sec
For of entries
439762.5 Ops/sec
Script Preparation code:
function makeid() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (var i = 0; i < 5; i++) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; } window.parentObj = {}; for (let i = 0; i < 100; i++) { window.parentObj[makeid()] = makeid(); }
Tests:
Object.entries
const newObj = {}; const parentObj = window.parentObj; Object.entries(parentObj).forEach(([k, v], i) => { newObj[k] = v; });
Object.keys
const newObj = {}; const parentObj = window.parentObj; Object.keys(parentObj).forEach((k, i) => { newObj[k] = parentObj[k]; });
Object.entries without array
const newObj = {}; Object.entries(window.parentObj).forEach((keyAndVal, i) => { newObj[keyAndVal[0]] = keyAndVal[1]; });
For in
const newObj = {}; const parentObj = window.parentObj; for (let key in parentObj) { newObj[key] = parentObj[key]; }
For of keys
const newObj = {}; const parentObj = window.parentObj; for (let key of Object.keys(parentObj)) { newObj[key] = parentObj[key]; }
For of entries
const newObj = {}; const parentObj = window.parentObj; for (let kv of Object.entries(parentObj)) { newObj[kv[0]] = kv[1]; }