# Comparison Operators

Comparison Operators

# Comparison Operators

Comparison operators allow you to test whether values are equivalent or whether values are identical. || is the OR operator, and && is the AND operator.

Comparison Operators in Detail
Operator Description Example
== is equal to
• 5==7 returns false
• 5==5 returns true
• 5=='5' returns true (type conversion)
=== is exactly equal to (value and type)
• 5==="5" returns false
• 5===5 returns true
!= is not equal
• 4!=3 returns true
• 4!=4 returns false
• 4!='4' returns false (type conversion)
!== is not equal (neither value or type)
• 4!=="4" returns true
• 4!==4 returns false
> is greater than
• 5>3 returns true
• 3>5 returns false
< is less than
• 1<2 returns true
• 2<1 returns false
>= is greater than or equal to
• 5>=5 returns true
• 5>=4 returns true
• 5>=6 returns false
<= is less than or equal to
• 5<=5 returns true
• 5<=7 returns true
• 5<=4 returns false

### Comparison Operators - More Examples

```var foo = 1;
var bar = 0;
var baz = '1';
var bim = 2;

foo == bar;             // returns false
foo != bar;             // returns true
foo == baz;             // returns true; careful!

foo === baz;            // returns false
foo !== baz;            // returns true
foo === parseInt(baz);  // returns true

foo > bim;              // returns false
bim > baz;              // returns true
foo <= baz;             // returns true```