Comparing to null with double-equals
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`
}
More fire tips
Removing duplication with ternary operators
The ternary operator can be used at many levels. The further we move it into a statement, the more duplication it can save us.
Read fire tip