Sometimes, we want to check if a value is not null and not empty string in JavaScript.
In this article, we’ll look at how to check if a value is not null and not empty string in JavaScript.
How to check if a value is not null and not empty string in JavaScript?
To check if a value is not null and not empty string in JavaScript, we can use the !== operator.
For instance, we write
if (data !== null && data !== "") {
// ...
}
to check if data isn’t null and data isn’t an empty string with
data !== null && data !== ""
Conclusion
To check if a value is not null and not empty string in JavaScript, we can use the !== operator.