How to check for not null with JavaScript?

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.