course content

Course Content

Introduction to JavaScript

Logical OperationsLogical Operations

Now we will consider the logical operations. Logical operations are used between two boolean values.

Logical operators

There are 3 logical operators:

  • AND (&&);
  • OR (||);
  • NOT (!).

AND

The AND (&&) logical operator returns true if two values equal true:

The AND (&&) operator requires that all values be true in order to return true.

OR

The OR (||) logical operator returns true if at least one value is true:

NOT

The NOT (!) operator inverts the value: not true is false; not false is true:

Using

Logical operations are used to combine some conditions. If you need to check that two values are greater than 4 (or 1), you should use the AND (&&) operator:

Priority

Logical operations execute after comparison operations and comparison operations execute after math operations.

Note

Similar to other operations, you can use parentheses () to increase the priority of execution.

1. What will be the output?
2. What will be the output?
3. What will be the output?

question-icon

What will be the output?

Select the correct answer

question-icon

What will be the output?

Select the correct answer

question-icon

What will be the output?

Select the correct answer

Section 3.

Chapter 7