A js problem occurs simultaneously.

Source: Internet
Author: User

A problem occurred in the company's technical group:

What is the return value of "" = 0 in JS. Of course, most JS veterans know that true is returned. At this time, Xiaodong Daxia posted such a paragraph, decisive collections.

 

11.9.3 the abstract computing ity comparison algorithm
The comparison X = Y, where X and Y are values, produces true or false. Such a comparison is
Saved med as follows:
1. If type (X) is different from type (Y), go to Step 14.
2. If type (X) is undefined, return true.
3. If type (X) is null, return true.
4. If type (X) is not number, go to Step 11.
5. If X is Nan, return false.
6. If y is Nan, return false.
7. If X is the same number value as Y, return true.
8. If X is + 0 and Y is −0, return true.
9. If X is −0 and Y is + 0, return true.
10. Return false.
11. If type (X) is string, then return true if X and Y are exactly the same sequence of characters (same
Length and same characters in corresponding positions). Otherwise, return false.
12. If type (X) is Boolean, return true if X and Y are both true or both false. Otherwise, return false.
13. Return true if x and y refer to the same object or if they refer to objects joined to each other (see
13.1.2). Otherwise, return false.
14. If X is null and Y is undefined, return true.
15. If X is undefined and Y is null, return true.
-56-
16. If type (X) is number and type (Y) is string,
Return the result of the comparison X = tonumber (y ).
17. If type (X) is string and type (Y) is number,
Return the result of the comparison tonumber (x) = y.
18. If type (X) is Boolean, return the result of the comparison tonumber (x) = y.
19. If type (Y) is Boolean, return the result of the comparison X = tonumber (y ).
20. If type (X) is either string or number and type (Y) is object,
Return the result of the comparison X = toprimitive (y ).
21. If type (X) is object and type (Y) is either string or number,
Return the result of the comparison toprimitive (x) = y.
22. Return false.

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.