I have a function that has about 30 indexOf statements, and I
think it would be faster and easier to read if I used .test() instead:
[
koukia.ca...]
According to this, I can use the /x modifier:
[
tutorialrepublic.com...]
so my code can look like:
var expr = /
csdude | // my name
foo | // random
bar // another random
/gix;
That cuts my code in less than half! And according to the benchmark test, it should be faster to process.
JSFiddle throws an error when I do this, though, so I'm not sure if this is going to be OK with all browsers? I can't find the compatability of /x on Google, and caniuse.com doesn't tell me unless I should search for it a different way:
[
developer.mozilla.org...]
[
caniuse.com...]