Object loops: for...in vs Object.keys+forEach (ES5) vs for...of (ES6) vs Object.entries (ES8)
one year ago
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0
Test name |
Executions per second |
for...in |
66841.7 Ops/sec |
Object.keys+forEach (ES5) |
41241.4 Ops/sec |
for...of - keys (ES6) |
42129.6 Ops/sec |
for...of - values (ES6) |
76194.9 Ops/sec |
for...of - entries (ES8) |
18627.0 Ops/sec |
Object.entries (ES8) |
20342.9 Ops/sec |
Tests:
-
for...in
-
Object.keys+forEach (ES5)
-
for...of - keys (ES6)
-
for...of - values (ES6)
-
for...of - entries (ES8)
-
Object.entries (ES8)
Open this result on MeasureThat.net