+ 1
Why alert(!(4%2)) returns true?
I got it right in challenges but don't understand the logic behind it.
1 Antwort
+ 8
What's 4 % 2? zero right? in term of boolean, zero was false and other non-zero values were true.
And then there's the unary logical NOT operator ! whose work was to invert whatever operand it was given, and since it is a logical operator, it gives back a boolean.
So !( 4 % 2 ) is !( 0 ) means !( false ) means ...
Voila!