Other than creating a function, is there a shorter way to check if a value is undefined
,null
or false
only in JavaScript?
The below if statement is equivalent to if(val===null && val===undefined val===false)
The code works fine, I'm looking for a shorter equivalent.
if(val==null || val===false){
;
}
Above val==null
evaluates to true both when val=undefined
or val=null
.
I was thinking maybe using bitwise operators, or some other trickery.
Well, you can always "give up" :)
function b(val){
return (val==null || val===false);
}