Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Searching in an array of objects
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0
Browser:
Firefox 127
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
For
48225864.0 Ops/sec
Array.find
41499496.0 Ops/sec
Array.findIndex
43008880.0 Ops/sec
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')];