Q:

JavaScript Replace function check

I am doing a java script replace as : 
var featureTitle;
featureTitle = row.cells[1].text();
if (!featureTitle.indexOf('*') != -1)
{
    featureTitle = featureTitle.replace('*', '');
}

Is if (!featureTitle.indexOf('*') != -1) needed check here??
OR replace will take care of it?

A:

replace will do nothing if the asterisk does not exist, so it's safe to call without the check first.
Speaking of which, the check has a bug which makes the code as a whole behave incorrectly:
if (!featureTitle.indexOf('*') != -1) // what's that ! in front doing?

Since !featureTitle.indexOf('*') is always true or false, this condition will always succeed (both booleans compare unequal to -1).

