Learning javascript and came across something like this:
if (obj.indexOf("someValue") > -1) {
do.something();
}
Without posting the whole script, the indexOf() method was only being used to check for a value in a string.
My question is why you would do that instead of:
if (obj.match(/someValue/g)) {
do.something();
}
Is this for legacy browser support or is it faster for some reason?