Is there any better way of doing this?
if(borrar() !== false)
{
alert(\'tatatata bum bum bum prapra\');
}
return false;
If you want to check for false and alert if not, then no there isn't.
If you use if(val)
, then anything that evaluates to 'truthy', like a non-empty string, will also pass. So it depends on how stringent your criterion is. Using ===
and !==
is generally considered good practice, to avoid accidentally matching truthy or falsy conditions via JavaScript's implicit boolean tests.