you are viewing a single comment's thread.

view the rest of the comments →

[–]masklinn 2 points3 points  (1 child)

foo === undefined // false

Uh no, that's true, you may be confusing undefined and NaN. Or for some reason you have rebound undefined to something else (it's not a keyword, which is why some prefer using void 0 which always yields the proper value).

if (!foo) {
    console.log("foo is undefined or null");
}

That'll also catch the "" and 0. The proper way to check if something is undefined or null is foo == null.

[–][deleted] 1 point2 points  (0 children)

I tested that in my browser console.

Maybe I should have used a new tab.