Javascript && operator versus nested if statements: what is faster?

The performance difference is negligible. The && operator won’t check the right hand expression when the left hand expression evaluates false. However, the & operator will check both regardless, maybe your confusion is caused by this fact.

In this particular example, I’d just choose the one using &&, since that’s better readable.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)