In our lives, we are constantly writing code, writing JavaScript, and seldom have time to do conceptual research. I am not busy today. I have studied the relationship between "null" and "0. I hope you will get some results after reading this article.
Copy codeThe Code is as follows:
Alert (null> = 0)
Copy codeThe Code is as follows:
What will pop up in the above Code? False? True? It is actually true. So why? Why is "null> = 0" true? If the value is null> = 0, it is converted to the numeric type. When performing a null> = 0 comparison, it is the answer obtained by comparing null <0. If a = B is false, if a = B is true, that is, if 0 <0 is false, that is, if null <0 is false, then null> 0 is true. So null> = 0 is true.
Copy codeThe Code is as follows:
Alert (null = 0)
What will pop up in the above Code? False? True? It is actually false. "Null = 0" is a special processing. It is not converted to a numeric type and not to a numeric value. However, if the left side is a numeric value on the right side of the string, it is converted. "Null" is an object (empty object without any attributes or methods ). "0" is a number. As mentioned above, "=" is not a conversion type, but a comparison. Therefore, it is false.
Why is "null = 0" false, but "null> = 0" true? This small problem is analyzed here. I also learned a lot in the analysis process. I think you will have some gains when looking at it again. All of the above are my opinions. If you cannot understand anything, you are welcome to join us in learning.