Check for false

前端 未结 6 2002
孤城傲影
孤城傲影 2021-02-05 02:43

Is there any better way of doing this?

if(borrar() !== false)
{
    alert(\'tatatata bum bum bum prapra\');
}
return false;
6条回答
  •  悲&欢浪女
    2021-02-05 03:16

    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.

提交回复
热议问题