Skip to content

Fastest method for Javascript substring search

I have a mobile application that needs to search through a rather large array and I’m experiencing some optimization issues with it. ¬†So, I decided to run some tests to see which function would be the fastest between indexOf, search, and includes.

I first tested all three with a static search value, search performed the best:


But, with a variable, indexOf performed the best:


I was able to perform these tests pretty easily using :)

Published inJavaScriptScripting

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *