1️⃣

3.1 Relational Operators

3.1 Relational Operators

What Are Relational Operators?

These operators all you to compare values of different types (not just numbers).

Using these operators, we can create "conditions". A condition is a statement that evaluates to either true or false.

Relational Operators

NamePurpose
==
Compares the equality of two operands without considering type.
===
Compares equality of two operands with type.
!=
Compares INequality of two operands.
>
Checks whether the left operand is greater than the right operand.
<
Check whether the left operand is less land the right operand.
>=
Checks whether left operand is greater than or equal to the right operand.
<=
Checks whether left operand is less than or equal to right operand.

Examples

The following demonstrates how comparison operators perform different tasks.

// these are the operands
let a = 5, b = 10, c = "5";
let x = a;

a == c;  // true
a === c; // false
a == x;  // true
a != b;  // true
a > b;   // false
a < b;   // true
a >= b;  // false
a <= b;  // true
a >= c;  // true
a <= c;  // true

Next Section

2️⃣
3.2 Logical Operators

⚖️

Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License. If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact classes@code4tomorrow.org for inquiries.