Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0
Chrome 129
Windows
Desktop
3 months ago
Test name Executions per second
toLowerCase_includes 20889.9 Ops/sec
Regex_indexOf 24866.0 Ops/sec
Script Preparation code:
x
 
var words = Array.from({ length: 1000 }, (_, i) => `word${i + 1}`);
var searchString = "WORD512";
var searchStringRegex = new RegExp(searchString, 'i');
Tests:
  • toLowerCase_includes

     
    const filteredCase1 = words.filter(word => word.toLowerCase().includes(searchString.toLowerCase()));
  • Regex_indexOf

     
    const filteredCase2 = words.filter(word => searchStringRegex.test(word));