Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.includes vs String.includes vs Object Hashmap (fix)
(version: 0)
Matching a string against more than one possibility.
Comparing performance of:
Array.includes vs String.includes vs Object Hash-map
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var testArray = ['foo', 'bar']; var testString = "foo,bar"; var objectHash = { foo: true, bar: true, };
Tests:
Array.includes
const testStrFirst = 'foo'; testArray.includes(testStrFirst); const testStrSecond = 'bar'; testArray.includes(testStrSecond); const testStrNotMatch = 'baz'; testArray.includes(testStrNotMatch);
String.includes
const testStrFirst = 'foo'; testString.includes(testStrFirst); const testStrSecond = 'bar'; testString.includes(testStrSecond); const testStrNotMatch = 'baz'; testString.includes(testStrNotMatch);
Object Hash-map
const testStrFirst = 'foo'; objectHash[testStrFirst]; const testStrSecond = 'bar'; objectHash[testStrSecond]; const testStrNotMatch = 'baz'; objectHash[testStrNotMatch];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Array.includes
String.includes
Object Hash-map
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:
equality vs includes
chain of or equals vs includes but smaller
=== vs includes
equals vs includes
equals vs includes (one value)
Comments
Confirm delete:
Do you really want to delete benchmark?