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.