Comparison Operators

By: Dusty Arlia
Published on June 6, 2012
Last updated on Monday, July 06, 2015 at 1:49 PM
Total updates: 7

Comparison Operator Definition
== Equal to: Compares two values to see if they are the same. If they are the same, then this comparison is true. It can be used to compare both numbers or strings.
!= Not equal to: Compares two values to see if they are NOT the same. If they are NOT the same, then this comparison is true. Can be used to compare both numbers or strings.
=== Strict equal to: Compares both the values and data types of two expressions. For example: '3' == 3 is true, but '3' === 3 is false ('3' is a string).
!== Strict not equal to: Compares both the values and data types of two expressions. For example: '3' != 3 is false (these two values are the same, resulting in this comparison being false), but '3' !== 3 is true (these two expressions have different data types resulting in this comparison being true).
> Greater than: Compares two numbers and checks if the number on the left side is greater than the number on the right. For example: 4 > 2 is true.
< Less than: Compares two numbers and checks if the number on the left side is less than the number on the right. For example: 4 < 2 is false.
>= Greater than or equal to: Compares two numbers and checks if the number on the left side is greater than or the same value as the number on the right. For example: 2 >= 2 is true.
<= Less than or equal to: Compares two numbers and checks if the number on the left side is less than or the same value as the number on the right. For example: 2 <= 2 is true.

Comments:

Ad:

Ad: