Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
medium size array find object with certain properties
(version: 0)
Compare the new ES6 spread operator with the traditional concat() method
Comparing performance of:
find lodash vs for in vs find native
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.js"></script>
Script Preparation code:
var media = {}; const DATA_LENGTH = 4000; for (let i = 1; i <= DATA_LENGTH; i++) { media["c42dec10-6328-4ac1-97af-63ec8d8d302" + i] = { "mediumId": "c42dec10-6328-4ac1-97af-63ec8d8d302" + i, "cid": "1143200002A71", "uid": null, "active": true, "revoked": false, "personId": "0e3cf8c1-7a26-4335-9c7a-c133d218011" + i }; }
Tests:
find lodash
_.find(Object.values(media), { personId:"0e3cf8c1-7a26-4335-9c7a-c133d2180112000", revoked: false })
for in
var found = null; for (let key in media) { if (media.hasOwnProperty(key)) { let value = media[key]; if (media[key].personId === "0e3cf8c1-7a26-4335-9c7a-c133d2180112000" && media[key].revoked === false) { found= media[key]; break; } } }
find native
Object.values(media).find(m => m.personId === "0e3cf8c1-7a26-4335-9c7a-c133d2180112000" && m.revoked === false)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
find lodash
for in
find native
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!
Related benchmarks:
native find vs lodash _.find
Compare prototype.find vs lodash/find
native find vs [0]
array find vs some in Array with Objects
native find vs for..in
Comments
Confirm delete:
Do you really want to delete benchmark?