Comparing to null with double-equals
JavaScriptAll snippets in this category →
Posted on Compare a variable to null
using two equal signs to check if it is null
or undefined
at the same time.
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}