Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for...in vs for...of
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser:
Chrome 142
Operating system:
Linux
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
of
9185.6 Ops/sec
in
9022.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function removeIdNewV2(value) { if ('_id' in value) { delete value._id; } const iterator = Array.isArray(value) ? value : Object.keys(value); for (const iteratee of iterator) { const element = value[iteratee] ?? iteratee; if (typeof element === 'object') { removeIdNewV2(element); } } } function removeIdOldV3(value) { if ('_id' in value) { delete value._id; } for (const objectKey in value) { var element = value[objectKey]; if (typeof element === 'object') { removeIdOldV3(element); } } } function getRandom(min, max) { return ~~(Math.random() * (max - min + 1) + min); } function setId(pointer, counter) { if (getRandom(1, 2) % 2) { pointer._id = 'randomId'; } if (counter < 1000) { pointer['deeper'] = {}; setId(pointer['deeper'], ++counter); } } var element = {};
Tests:
of
setId(element, 0); removeIdNewV2(element);
in
setId(element, 0); removeIdOldV3(element);