
Object-Oriented JavaScript - Second Edition
By :

There are three operators, called logical operators, that work with Boolean values. These are:
!
– logical NOT (negation)
&&
– logical AND
||
– logical OR
You know that when something is not true, it must be false. Here's how this is expressed using JavaScript and the logical !
operator:
> var b = !true;
> b;
false
If you use the logical NOT twice, you get the original value:
> var b = !!true;
> b;
true
If you use a logical operator on a non-Boolean value, the value is converted to Boolean behind the scenes:
> var b = "one";
> !b;
false
In the preceding case, the string value "one"
is converted to a Boolean, true
, and then negated. The result of negating true
is false
. In the next example, there's a double negation, so the result is true
:
> var b = "one";
> !!b;
true
You can convert any value to its Boolean equivalent using a double negation. Understanding how any value converts to a Boolean is important. Most values convert to true
with the exception...
Change the font size
Change margin width
Change background colour