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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Browser:
Chrome 107
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Object.entries
83164.9 Ops/sec
Object.keys
206315.3 Ops/sec
Object.entries without array
85819.7 Ops/sec
For in
184445.3 Ops/sec
For of keys
205639.2 Ops/sec
For of entries
84150.2 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]; }