Categories
JavaScript Answers

How to check for not null with JavaScript?

Spread the love

Sometimes, we want to check for not null with JavaScript.

In this article, we’ll look at how to check for not null with JavaScript.

How to check for not null with JavaScript?

To check for not null with JavaScript, we can use the !== operator.

For instance, we write

if (val !== null) {
  //...
}

to check if val isn’t equal to null with

val !== null

Conclusion

To check for not null with JavaScript, we can use the !== operator.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *