Of course, you could go back to the more explicit null and undefined check if you think you might get other falsy values that don't fall into that condition like 0, empty string, false, and NaN.
But to answer the question, I prefer just 'if' whenever possible.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Wouldn't you put the null and undefined check first to have a quick return?
Of course, you could go back to the more explicit null and undefined check if you think you might get other falsy values that don't fall into that condition like
0
, empty string,false
, andNaN
.But to answer the question, I prefer just 'if' whenever possible.