JavaScript Comparison
The logical processes that establish equality or difference between the values are often carried out using the comparison operators.
Operators are used to carrying out certain logical and mathematical operations on operands. JavaScript provides comparison operations just like C, C++, Java, Python, and many other languages. To assess if variables or values in logical expressions are equal or different, comparison operators are utilized.
JavaScript offers support for a number of comparison operators, including:
- Equality Operators
- Relational Operators
Equality Operators
1. Equality (==)
This operator is utilized to determine whether two operands are equal. The condition is true if equal; otherwise, it is false.
2. Inequality(!=)
The inequality of two operands is compared using this operator. If equal, the condition is true; otherwise, it is false.
3. Strict equality(===)
This operator is utilized to assess the type equality of two operands. The condition is true if the value and type are both equal; otherwise, it is false.
Note: For information on the key distinctions between them, see the page on the comparison operators "===" and “==.”
4. Strict inequality(!==)
To compare the inequality of two operands with type, use this operator. The condition is true if the value and type are not the same, else it is false.
Relational Operators
1. Greater than operator(>)
This operator is used to determine whether the value on the left is greater than the value on the right. The condition is true if the value is bigger; else, it is false.
2. Greater than or equal operator(>=)
This operator is used to determine if the right side operand and the left side operand are larger than or equal. The condition is true if the value is more than or equal to, else it is false.
3. Less than operator(<)
This operator is used to determine whether the value on the left side is less than the value on the right. The condition is true if yes, else it is false.
4. Less than or equal operator(<=)
This operator is used to determine if the value of the right side operand is greater than or equal to the value of the left side operand. The condition is true if yes, else it is false.