DEV Community

Discussion on: Avoid boolean values comparison with "==" in JavaScript

 
icatalina profile image
Ignacio Catalina

If you need to check for undefined and null just do

if (variable === undefined || variable === null) {

if I see code doing:

if (variable == null) {

I have no way to know if you actually wanted to check only for null or null and undefined.

It is always better to be explicit.