" greater than operator; 7. ">=" greater than or equal to operator; 8. "<=" less than or equal to operator."/> " greater than operator; 7. ">=" greater than or equal to operator; 8. "<=" less than or equal to operator.">

Home >Web Front-end >JS Tutorial >What are the javascript relational operators?

What are the javascript relational operators?

青灯夜游
青灯夜游Original
2021-12-06 11:11:424894browse

Javascript relational operators include: 1. "==" equality operator; 2. "===" congruence operator; 3. "!=" inequality operator; 4. "!= =” is not equal to the operator; 5. “<” is less than the operator; 6. “>” is the greater than operator; 7. “>=" is the greater than or equal to operator; 8. “<=" is less than or equal to the operator .

What are the javascript relational operators?

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.

Relational operator

Through the relational operator, you can compare the size relationship between two values

If the relationship is established, it will return true, if the relationship is not established, return false immediately.

##<less thanx < y means if If x is less than y, then it is true>

is greater thanx > y means if x is greater than y, then it is true>=Greater than or equalx >= y means if x is greater than or equal to y, it is true<=Less than or equal tox <= y means true if x is less than or equal to y
OperatorNameExample
==Equal tox == y means if x is equal to y, it is true
===Congruent x === y means true if x is equal to y and x and y are of the same type
!=Not equalx != y means if x is not equal to y, it is true
!==Not congruentx !== y means True if x is not equal to y, or if x and y are of different types

1. Greater than sign (>)
⑴ Determine whether the value on the left side of the symbol is greater than the value on the right side

⑵ If the relationship is established , returns true; if the relationship is not established, returns false.

⑶Example 1: The relationship is established

⑷Example 1: The relationship is not established

2. Greater than or equal to (>=)

Determine whether the value on the left side of the symbol is greater than or equal to the value on the right side

# #3. Less than sign (<)

Determine whether the value on the left side of the symbol is less than the value on the right side

If the relationship is established, return true; if the relationship is not established, return false .

4. Less than or equal to (<=)

Determine whether the value on the left side of the symbol is less than or equal to the value on the right side

5. Non-numeric cases

⑴When comparing non-numeric values, they will be converted into numbers, and then Compare

⑵ Any value compared with NaN is false

⑶ If the values ​​on both sides of the symbol are When a string is entered, it will not be converted into a number for comparison;

but the Unicode encoding of the characters in the string will be compared separately

⑷Compare the character encoding When comparing, one digit is compared;

If the two digits are the same, the next digit is compared, so it is used to sort English;

It is meaningless when comparing Chinese.

⑸If you compare two string-type numbers, you may get unexpected results

Note: When comparing two string-type numbers, When it comes to numbers, you must transform

[Related recommendations:

javascript learning tutorial

]

The above is the detailed content of What are the javascript relational operators?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn