In JavaScript I have a variable initialized with undefined
. Now I'd like to check if it is either true
or false
.
Is there a statement more elegant than the following?
if (isValid === true || isValid === false) {
// do something
}
In JavaScript I have a variable initialized with undefined
. Now I'd like to check if it is either true
or false
.
Is there a statement more elegant than the following?
if (isValid === true || isValid === false) {
// do something
}
How about checking if it is not undefined?
if (isValid !== undefined) {
// do something
}