I tend to do stuff like this:
Even on single substring matches where indexOf would work - Just because it's more convenient - quicker to type, and extensible.
But if I'm using quite a few of these, is there any performance impact - is testing a regex literal slower than indexOf?
Code:
if(/string/.test(variable)) { ....
But if I'm using quite a few of these, is there any performance impact - is testing a regex literal slower than indexOf?
Comment