Logical Operators: !, ||, &&

Learn operators that will make our conditional code much more interesting and powerful. Learn how to combine operators for more complex logic.

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”.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy