Performance test stuff | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Performance test stuff

Iā€™m curious what the fastest way to find if a string includes another string is. there are some sources online but they all have different answers So which one of these (or others I havenā€™t included) would be the best performance? Var g = ā€˜hello worldā€™; solution 1: g.includes(ā€˜zā€™) solution 2: g.indexOf(ā€˜zā€™) != -1 solution 3: /z/.test(g)

12th Apr 2022, 12:07 PM
ITDW
2 Respostas
13th Apr 2022, 11:25 PM
CalviÕ²
CalviÕ² - avatar
+ 1
for premformence, Regex (3) is the fastes it is the most used for large data tests
12th Apr 2022, 4:15 PM
Mohamed Ayaou