Es6 how to check if value is not null or undefined?
How to check if value id null or undefined.
if(value !== undefined || value !== null){
simple way is just check if has value! Like
if(value) {
// ...
}
will return true if value is not:
null, undefined, NaN, empty string (""), 0, false
It’s fulfill our requirements but also check additional conditions
Like we want to check id is null or undefined but in response we got id = 0
In this condition it will fail because we just need to check null or undefined
// ...
}
Comments