3 ms·
A perfect example of why "~x.indexOf(y)" may actually be better... you just messed up, as the alternative should be "x.indexOf(y) !== -1" or "x.indexOf(y) >= 0"
by tracker1 12y ago
A perfect example of why "~x.indexOf(y)" may actually be better... you just messed up, as the alternative should be "x.indexOf(y) !== -1" or "x.indexOf(y) >= 0" or "x.indexOf(y)+1" ...
In any case, it's all a matter of style... because if you don't know that indexOf will return 0 for a positive match, you will still mess up.