DEV Community 👩‍💻👨‍💻

Max Angelo Dapitilla Perin
Max Angelo Dapitilla Perin

Posted on

Answer: How do I check for null values in JavaScript?

To check for null SPECIFICALLY you would use this:

if (variable === null)

This test will ONLY pass for null and will not pass for "", undefined, false, 0, or NaN.

Additionally, I've provided absolute checks for each "false-like" value (one that would return true…

Top comments (0)

Create an Account!

👀 Just want to lurk?

That's fine, you can still create an account and turn on features like 🌚 dark mode.