Back to Library
Region:
Switch to ID
Advanced freeCodeCamp • top-learn-data-types-and-conditionals
Learn Data Types and Conditionals Lesson F
Lesson Overview
You know that JavaScript has a variety of data types, including strings, numbers and booleans. You can use comparison operators to compare these data types and make decisions based on the results.
You know that JavaScript has a variety of data types, including strings, numbers and booleans. You can use comparison operators to compare these data types and make decisions based on the results.
The following comparison operators are available in JavaScript:
| Operator | Description | Example |
|---|---|---|
| == | Equal (value comparison) | x == y |
| != | Not equal | x != y |
| > | Greater than | x > y |
| < | Less than | x < y |
| >= | Greater than or equal to | x >= y |
| <= | Less than or equal to | x <= y |
To use a comparison in a variable assignment, you can use the == operator. For example:
let x = 5;
let y = 5;
let result = x == y;
console.log(result); // true