Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
remove undefined from object. entries.filter vs for of vs for in
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/125.0.0.0 Safari/537.36
Browser:
Chrome 125
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
filter object entries
1486108.9 Ops/sec
for of Object.entries
1546759.2 Ops/sec
for in
1731905.9 Ops/sec
Script Preparation code:
const testObject = { a: 'a', b: undefined, c: 'c', d: undefined, e: undefined }
Tests:
filter object entries
const testObject = { a: 'a', b: undefined, c: 'c', d: undefined, e: undefined } Object.fromEntries(Object.entries(testObject).filter(([_, value]) => value !== undefined))
for of Object.entries
const testObject = { a: 'a', b: undefined, c: 'c', d: undefined, e: undefined } const testObjectCopy = {...testObject} for (const [prop, value] of Object.entries(testObjectCopy)) if (value === undefined) delete testObjectCopy[prop]
for in
const testObject = { a: 'a', b: undefined, c: 'c', d: undefined, e: undefined } const testObjectCopy = {...testObject} for (const prop in testObjectCopy) if (testObjectCopy.hasOwnProperty(prop) && testObjectCopy[prop] === undefined) delete testObjectCopy[prop]