Logical Operators: !, ||, &&
Explore how to use JavaScript logical operators NOT, OR, and AND within if-statements. Understand their rules and precedence to create complex logical conditions that control code flow effectively.
We'll cover the following...
We'll cover the following...
Let’s introduce some logical operators to make if-statements more powerful.
!
The ! operator is called the “not”-operator. It does two things to a value: it coerces it to either true or false, and then gives the opposite value. Falsey values become true and truthy values become false.
For example, !true will become false. !0 will become true. !'' will become true. Think of this operator as saying “This item is NOT true” or “This item is NOT false”.
! in if-statements
We can use this in ...