pub enum CompOp {
Equal,
NotEqual,
StrictEqual,
StrictNotEqual,
GreaterThan,
GreaterThanOrEqual,
LessThan,
LessThanOrEqual,
In,
InstanceOf,
}
Expand description
A comparison operator compares its operands and returns a logical value based on whether the comparison is true.
The operands can be numerical, string, logical, or object values. Strings are compared based on standard
lexicographical ordering, using Unicode values. In most cases, if the two operands are not of the same type,
JavaScript attempts to convert them to an appropriate type for the comparison. This behavior generally results in
comparing the operands numerically. The sole exceptions to type conversion within comparisons involve the ===
and !==
operators, which perform strict equality and inequality comparisons. These operators do not attempt to convert the operands
to compatible types before checking equality.
More information:
Variants
Equal
The equality operator converts the operands if they are not of the same type, then applies strict comparison.
Syntax: y == y
If both operands are objects, then JavaScript compares internal references which are equal when operands refer to the same object in memory.
More information:
NotEqual
The inequality operator returns true
if the operands are not equal.
Syntax: x != y
If the two operands are not of the same type, JavaScript attempts to convert the operands to an appropriate type for the comparison. If both operands are objects, then JavaScript compares internal references which are not equal when operands refer to different objects in memory.
More information:
StrictEqual
The identity operator returns true
if the operands are strictly equal with no type
conversion.
Syntax: x === y
Returns true
if the operands are equal and of the same type.
More information:
StrictNotEqual
The non-identity operator returns true
if the operands are not equal and/or not of the
same type.
Syntax: x !== y
Returns true
if the operands are of the same type but not equal, or are of different type.
More information:
GreaterThan
The greater than operator returns true
if the left operand is greater than the right
operand.
Syntax: x > y
Returns true
if the left operand is greater than the right operand.
More information:
GreaterThanOrEqual
The greater than or equal operator returns true
if the left operand is greater than or
equal to the right operand.
Syntax: x >= y
Returns true
if the left operand is greater than the right operand.
More information:
LessThan
The less than operator returns true
if the left operand is less than the right operand.
Syntax: x < y
Returns true
if the left operand is less than the right operand.
More information:
LessThanOrEqual
The less than or equal operator returns true
if the left operand is less than or equal to
the right operand.
Syntax: x <= y
Returns true
if the left operand is less than or equal to the right operand.
More information:
In
The in
operator returns true
if the specified property is in the specified object or
its prototype chain.
Syntax: prop in object
Returns true
the specified property is in the specified object or its prototype chain.
More information:
InstanceOf
The instanceof
operator returns true
if the specified object is an instance of the
right hand side object.
Syntax: obj instanceof Object
Returns true
the prototype
property of the right hand side constructor appears anywhere
in the prototype chain of the object.
More information: