Troublesome null> 0, null = 0, and null> = 0

Source: Internet
Author: User

Occasionally, I saw this problem in a blog. At that time, the author cited a lot of ecmascript specifications, which are still in English, and I was dizzy. Now I will put the conclusions of others here. If you have time, write this blog according to your own understanding.

----------- Conclusion -------------

  1. Relational operators and equal operators are not in the same category.
  2. Relational operators, in design, always need to convert the element to a number. While equality operators are not considered in design.
  3. The most important thing is not to take the result of A> B, A = B for granted to establish a contact with a> = B. the correct relationship with the original design idea is that A> B and A> = B are a group. A = B and other equal operators are a group. for example, a = B,! = B,! = B.

Therefore, we look at this problem in turn:

Null> 0//If null attempts to convert to number, it is 0. Therefore, the result is false,Null> = 0//If you try to convert null to number, the value is 0 and the result is true.Null= 0//Null is designed, and transformation is not attempted here. Therefore, the result is false.

 

Not complete...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.