In my code I have the following:
console.log(props.acknowledged) // false
console.log(props.type === "SOMETHING") //false
console.log(!props.acknowledged && !props.type === "SOMETHING") //false
How is that a !false && !false results to a false?
javascript
In my code I have the following:
console.log(props.acknowledged) // false
console.log(props.type === "SOMETHING") //false
console.log(!props.acknowledged && !props.type === "SOMETHING") //false
How is that a !false && !false results to a false?
Best Answer
You need to add parantheses like this:
!(props.type === "SOMETHING")
The priority of
!
is more than===
operator so your code will be evaluated as below:so if
props.type
equals say"something else"
, it will become binary value offalse
and your whole expression issomething && false
which isfalse
.I think what you wanted to to is:
or even