Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
[JS] Object.keys + map vs for...in + push
(version: 0)
Comparing performance of:
Object.keys + map vs for...in + push
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const data = [ { "FACT_CD": "", "WH_CD": "", "LOC_TP": "", "LOC_NM": "", "RACK_TP": "", "RACK_DESC": "", "UNIT_TP": "", "UNIT_DESC": "", "SAP_TP": "", "SAP_NM": "", "USE_CC": "" } ]
Tests:
Object.keys + map
Object.keys(data[0]).map(prop => ( { wch: Math.max(prop.toString().length, ...data.map(obj => obj[prop] ? obj[prop].toString().length : 0)) } ));
for...in + push
const columnWidths = []; for (const prop in data[0]) { const maxWidth = Math.max(prop.toString().length, ...data.map(obj => obj[prop] ? obj[prop].toString().length : 0)); columnWidths.push({ wch: maxWidth }); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object.keys + map
for...in + push
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!
Comments
Confirm delete:
Do you really want to delete benchmark?