Javascript
JavaScript Fundamentals -- Logical and Comparison Operators

Logical Operators -- Not

Mute
Current Time 0:00
/
Duration Time 0:00
Loaded: 0%
Progress: 0%
Stream TypeLIVE
Remaining Time -0:00
 
PRO

The logical operator "not" (!) lets you convert a truthy statement to a false result, and a falsy statement to a true result. Using two not operators together (!!) lets you convert a truthy value to the boolean result true and a falsy value to the boolean result false.

JavaScript will evaluate the not operator before any of the other logical operators; it has the highest precedence.

Here's a table of when an expression table will result in what value given two comparisons:

!truthy → false
!falsy → true
!!truthy → true
!!falsy → false

For more information on the logical or operator, read this blog post.

 

I finished! On to the next chapter