1if (variable !== null) {
2 //code
3}
4
5//Or, if you're expecting null as a string ('null'):
6
7if (variable != null) {
8 //code
9}
10
11//!== means not equal to, just like !=, but !== checks that the datatype is the same, whereas != doesn't.
12//Example: (null !== "null") = true (null != "null") = false
1//Even if the value is 0, this will execute.
2
3if (myVar !== null) {...}
4
5//If you don't want it to execute when it's 0, then set it as
6
7if (myVar) {...}
8
9//This will return false if var value is 0.