OPERATORS: ==
!= === !== > >= < <=
A comparison operator compares two operands and returns a Boolean value
(true or false) as to the validity of the comparison. Operands can be
of numeric or string type.
==
This is the equal operator and returns a boolean true if both the operands
are equal. JavaScript will attempt to convert different data types to
the same type in order to make the comparison. Assuming 'a' to be 2 and
'b' to be 4, the following examples will return a value of true:
a == 2
a == "2"
2 == '2'
!=
This is the not equal operator which returns a Boolean true if both
the operands are not equal. Javascript attempts to convert different
data types to the same type before making the comparison. The following
examples return a Boolean true:
a != b
a != 4
a != "2"
===
This is the strict equal operator and only returns a Boolean true if both
the operands are equal and of the same type. These next examples return
true:
a === 2
b === 4
!==
This is the strict not equal operator and only returns a value of
true if both the operands are not equal and/or not of the same type.
The following examples return a Boolean true:
a !== b
a !== "2"
4 !== '4'
>
This is the greater than operator and returns a value of true if the
left operand is greater than the right.:
a > 1
b > a
>=
This is the greater than or equal operator, which returns true if the
first operand is greater than or equal to the second. The following examples
return true:
a >= 1
a >= 2
b >= a
<
This is the less than operator and returns true if the left operand
is less than the right:
a < 3
a < b
<=
This is the less than or equal operator and returns true if the first
operand is less than or equal to the second. These next examples all return
true:
a <= 2
a <= 3
a <= b
|