I've been watching some videos from Tut+ about Js.They said that sometimes "undefined" is equal to "null". So, when does this happen ?
undefined == null
// => true
undefined === null
// => false
== tests for equality, === tests for identity (or strict equality). If in doubt, use ===
.
Just to add on , This question is somehow answered already, check here
You can just check if the variable has a truthy value or not. That means
if( value ) {
}
will evaluate to true if value is not:
null
undefined
NaN
empty string ("")
0
false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With