简体   繁体   English

JavaScript中的逻辑运算符评估

[英]Logical operators evaluation in javascript

Can you explain how works the Comparison Operators in JS: 您能否解释一下JS中的比较运算符如何工作:

 "a" > "A" // => why true?
  null == undefined; // and here as well?

and some others 和其他一些

   null >  0;
   null >= 0;

Strings are compared by their character codes, ie. 字符串通过其字符代码进行比较,即。 their positions in the Unicode table. 它们在Unicode表中的位置。
A is 65, a is 97. Therefore "a" > "A" . A是65, a是97。因此"a" > "A"

== is a loose comparison. ==是一个宽松的比较。 null == undefined is a special case, since the abstract equality comparison algorithm explicitly states that true should be returned when comparing these two values: null == undefined是一种特殊情况,因为抽象相等性比较算法明确指出在比较这两个值时应返回true

2. If x is null and y is undefined , return true . 2.如果xnull且y undefined ,则返回true
3. If x is undefined and y is null , return true . 3.如果x undefined且y为null ,则返回true

null > 0 is false, and null >= 0 is true because null , when converted to a number, is zero. null > 0为false, null >= 0为true,因为null转换为数字时为零。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM