Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Search in array of strings
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0
Browser:
Chrome 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
IndexOf
460155.5 Ops/sec
Includes
317222.4 Ops/sec
ForEach with === with length check
285828.7 Ops/sec
ForEach with ===
226563.8 Ops/sec
ForEach with ==
135990.2 Ops/sec
Script Preparation code:
var str = '1234567'; var arr = []; for (i = 0; i < 1000; i++) { arr.push([...Array(4 + Math.floor(Math.random() * 8))].map(i => (~~(Math.random() * 36)).toString(36)).join('')) }
Tests:
IndexOf
arr.indexOf(str)
Includes
arr.includes(str)
ForEach with === with length check
arr.forEach(s => { if (s.length === str.length && s === str) console.log('Finded!'); })
ForEach with ===
arr.forEach(s => { if (s === str) console.log('Finded!'); })
ForEach with ==
arr.forEach(s => { if (s == str) console.log('Finded!'); })