Avatar ·

How to check a variable for null, undefined or empty value in JavaScript?

Hi! I'm a beginner in JavaScript and often face the problem of checking variables for "emptiness". In different places I need to make sure that a variable is not null, undefined or an empty string ("") before using it in code. I've tried writing checks like this: ```javascript if (value !== null && value !== undefined && value !== "") { // do something } ``` But this looks cumbersome, especially when there are many such checks. Plus I'm not sure I've covered all cases — for example, what about the number 0, false, or an empty array? Should they be considered "empty"? I've heard that JavaScript has some tricks with type coercion, like `if (value)` or `if (!value)`. But this doesn't always work: `if (0)` returns false, even though zero is a perfectly valid value. And `if (