course content

Course Content

Introduction to JavaScript

Comparison OperationsComparison Operations

Comparisons are used to define conditions, checks, etc. These operations return a boolean value (true or false) that is used by other operators to perform certain actions.

Comparison operators

Comparison is made between two values using special operators:

  • equal to (==);
  • strict equal to (===);
  • not equal to (!=);
  • strict not equal to (!==);
  • greater than (>);
  • Greater than or equal to (>=);
  • less than (<);
  • less than or equal to (<=).

Equal and Not Equal

The equal to is the operation that returns true if the first value equal to the second value and returns false in other cases. Performs by == operator.

The not equal to is the operation that inverted to equal to. Performs by != operator.

Note

The = operator is an assignment when the == operator is a comparison. Don't make mistakes.

Strict comparison

The strict comparison checks types of the values. If the values are of different types, the strict equal to (===) will return false. The !== works inverted to ===.

Look at the examples:

Greater and Less

The greater than > operator returns true if the first value is greater than the second value.

The less than < operator works inverted to greater than:

Greater/Less than or Equal to

The operations greater than or equal to (>=) and less than or equal to (<=) combine two operations (greater/less than and equal to (==): if one of the conditions is satisfied, the result will be true (false otherwise):

Note

The >= operator combine > and == operators (not ===). The <= operator works similarly.

1. What will be the output?
2. What will be the output?
3. What will be the output?
4. 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

question-icon

What will be the output?

Select the correct answer

Section 3.

Chapter 6