How to use the javascript relational operator
This article is to share with you about how to use the javascript relation operator, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
There are four relational operators we can use in js, which are similar to those learned in mathematics, so let's introduce how to use them.
1. Both operands are strings. Compare ASCII encoding (case sensitive).
'13'
< '3';返回true,比较的是ASCII码 2、一个为数字,另一个不是数字,转化为数字。 '13' < 3;返回false,先转化为Number 3、NaN与任意数值比较均返回false(既不大于也不小于和等于)。 'a' >3; return false,'a' to Number. Compare NaN,NaN with any value and return false.
Example
Let result1 = 1 > false; console.log ("result1:" + result1); let result2 = 1 > true; console.log ("result2:" + result2); this is how to use the javascript relational operator. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.