JavaScript Operator: equal
[this page | pdf | back links]
In JavaScript,
the == operator
is the ‘equal to’ operator:
|
x
|
y
|
x == y
|
|
8
|
8
|
true
|
|
8
|
5
|
false
|
Note: if x and y
are of different type then some type coercion
will typically occur, and values that developers might not immediately
recognise as ‘equal’ may be deemed equal by this operator. If you want only
variables that are of the same type to pass the equality test then you should
use the strictly equal to operator, i.e. ===.
NAVIGATION LINKS
Contents | Prev | Next | JavaScript Operators