Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Comparison Operations | Basic Operations
Introduction to JavaScript

Comparison OperationsComparison Operations

Comparisons are used to define conditions, perform checks, and make decisions in JavaScript. These operations return a boolean value (true or false), which other operators use to determine certain actions.

Comparison Operators

JavaScript offers several comparison operators for comparing values:

  • 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 operation (==) returns true if the first value equals the second value and false otherwise.

Conversely, the Not Equal To operation (!=) returns true if the values are unequal.

Example:

Note

The = operator is for assignment, while == is for comparison. Be careful to distinguish them.

Strict comparison

Strict comparison checks the types of values and values. The Strict Equal To (===) operator returns true - if both the values and their types are the same, while !== returns true if they are different.

Example:

Greater and Less

The Greater Than (>) operator returns true if the first value exceeds the second. Conversely, the Less Than (<) operator returns true if the first value is less than the second.

Example:

Greater/Less Than or Equal to

The Greater Than or Equal To (>=) and Less Than or Equal To (<=) operators combine the corresponding comparison operators with Equal To (==). They return true if either of the conditions is satisfied.

Note

The >= operator combines > and ==, 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?

What will be the output?

Виберіть правильну відповідь

What will be the output?

Виберіть правильну відповідь

What will be the output?

Виберіть правильну відповідь

What will be the output?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 6
course content

Зміст курсу

Introduction to JavaScript

Comparison OperationsComparison Operations

Comparisons are used to define conditions, perform checks, and make decisions in JavaScript. These operations return a boolean value (true or false), which other operators use to determine certain actions.

Comparison Operators

JavaScript offers several comparison operators for comparing values:

  • 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 operation (==) returns true if the first value equals the second value and false otherwise.

Conversely, the Not Equal To operation (!=) returns true if the values are unequal.

Example:

Note

The = operator is for assignment, while == is for comparison. Be careful to distinguish them.

Strict comparison

Strict comparison checks the types of values and values. The Strict Equal To (===) operator returns true - if both the values and their types are the same, while !== returns true if they are different.

Example:

Greater and Less

The Greater Than (>) operator returns true if the first value exceeds the second. Conversely, the Less Than (<) operator returns true if the first value is less than the second.

Example:

Greater/Less Than or Equal to

The Greater Than or Equal To (>=) and Less Than or Equal To (<=) operators combine the corresponding comparison operators with Equal To (==). They return true if either of the conditions is satisfied.

Note

The >= operator combines > and ==, 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?

What will be the output?

Виберіть правильну відповідь

What will be the output?

Виберіть правильну відповідь

What will be the output?

Виберіть правильну відповідь

What will be the output?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 6
some-alt