Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Searching in an array of multiple objects
(version: 0)
Comparing performance of:
For vs Array.find vs Array.findIndex
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
const fruits = [ "Apple", "Banana", "Cherry", "Date", "Elderberry", "Fig", "Grape", "Honeydew", "Iced Raspberry", "Jackfruit", "Kiwifruit", "Lemon", "Mango", "Nectarine", "Orange", "Peach", "Pear", "Quince", "Raspberry", "Strawberry", "Tangerine", "Ugli Fruit", "Vine Fruit", "Watermelon", "Xigua" ]; var ARRAY = fruits.map((fruit) => ({name: fruit, desc: `Description ${fruit}`}));
Tests:
For
let el; for(var i=0; i < ARRAY.length; i++) { if(ARRAY[i].name == 'Jackfruit') { el = ARRAY[i]; break; } }
Array.find
const el = ARRAY.find((obj) => obj.name === 'Jackfruit');
Array.findIndex
const el = ARRAY[ARRAY.findIndex((obj) => obj.name === 'Jackfruit')];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
For
Array.find
Array.findIndex
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?