# Why Null==0 is false in JavaScript and null>=0 to True

Source: Internet
Author: User

At work we are constantly writing code, writing JavaScript, very little time for conceptual research. I have nothing to do today, I studied the relationship between "null" and "0". I hope you have seen the end of the harvest.

What does the above code pop up? False? True? is actually true. So why is it? Why is "Null>=0" true? When Null>=0, a strong switch to a numeric type. When making a null>=0 comparison, it is the answer that is obtained by comparing null<0, and if A=b is false, if a=b is true, that is, 0<0 is false, or null<0 is false, then null>0 is true. So null>=0 is true.

What does the code of the face pop up? False? True? is actually false. Null==0 "is a special treatment that does not turn into a numeric type and does not convert to a numeric value, but if the left side is a string to the right, the value is converted. "NULL" is an object (empty object with no properties and methods). and "0" is a number. Previously said "= =" does not convert the type, just comparison. So, false.

Why "Null==0" is false, but "null>=0" is true? This little problem is analyzed here. In the process of analysis I also learned a lot of things, I think we can see when there is a certain harvest it. Above all is the personal opinion, if has any understanding not to be in place, welcome to propose, everybody studies together ha.

Attach some reference

false false Td> Td>
 = 0 ' 0 ' [0] [] {} ' null [null] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' 0 ' 0 ' [0] [] {} ' NULL [NULL] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' [1] true true true true false true false true false false false false false false false true true true false false Span class= "false" >false false false false false false false false false false false true true false false false false false false false false false false false false false false true false false false false true false false false false false false false false false false false false false false false false false false false false false false false false false false true false false true false true false true false false false false false false false false false false false false false false true False true false false false false false false false true false false false false true false false false false false false false false false false false false false false false true false true false Span class= "false" >false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false true true true false false false false false false false false false false false false false true true true false false false false false false false false false false false false false true true false
false false Td> Td>
 = = 0 ' 0 ' [0] [] {} ' null [null] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' 0 ' 0 ' [0] [] {} ' NULL [NULL] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' [1] true false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false true False false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true false Span class= "false" >false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false false
" ' Td> "
 + 0 ' 0 ' [0] [] {} ' null [null] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' 0 ' 0 ' [0] [] {} ' NULL [NULL] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' [1] 0 ' ' 0 ' ' 0{} ' ' 0 ' 0 ' 0 ' nan nan ' 0NaN ' ' 0a ' infinity 1 ' ' 0 ' ' 0{} ' ' 0 ' ' 0undefined ' ' 0NaN ' ' 0a ' ' ' ' " ' 0 ' ' 0{} ' ' 0 ' ' 0undefined ' ' 0NaN ' ' 0a ' ' ' ' ' 0 ' ' 0 ' ' 0 ' " ' {} ' Span class= "string" " ' null ' " ' NaN ' ' NaN ' ' a ' ' Infinity ' ' 1 ' ' 1 ' ' {}0 ' ' {}0 ' ' {}0 ' ' {} ' ' {} ' ' {} ' ' {}null ' ' {}undefined ' ' {}nan ' ' {}nan ' ' {}a ' ' {}infinity ' ' {}1 ' ' 0 ' ' 0 ' ' 0 ' " ' {} ' Span class= "string" " ' null ' " ' NaN ' ' NaN ' ' a ' ' Infinity ' ' 1 ' ' 1 ' 0 ' null0 ' ' null0 ' ' null ' ' null{} ' /span> ' null ' 0 ' null ' nan nan ' Nullnan ' ' nulla ' infinity 1 ' null1 ' 0 ' ' 0 ' ' 0 ' " ' {} ' ' null ' ' undefined ' ' NaN ' Span class= "string" > ' NaN ' ' a ' ' 1 ' ' 1 ' ' 1 ' nan ' undefined0 ' ' undefined0 ' ' undefined ' Span class= "string" > ' undefined{} ' ' undefined ' nan ' undefined ' nan nan ' Undefinednan ' ' Undefineda ' nan nan ' undefined1 ' ' undefined1 ' nan ' NaN0 ' ' NaN0 ' ' NaN ' ' nan{} ' ' NaN ' nan ' NaN ' nan nan Span class= "string" > ' Nannan ' ' NaNa ' nan nan ' NaN1 ' ' NaN1 ' ' NaN0 ' ' NaN0 ' ' NaN0 ' ' NaN ' ' nan{} ' ' NaN ' ' nannull ' ' NaN ' ' nanundefined ' " Nannan ' ' Nannan ' ' NaNa ' ' naninfinity ' ' NaN1 ' ' NaN1 ' ' NaN1 ' ' A0 ' ' A0 ' ' A0 ' ' a ' ' a{} ' ' a ' ' anull ' ' a ' ' aundefined ' ' Anan ' ' Anan ' ' AA ' ' ainfinity ' ' A1 ' ' A1 ' ' A1 ' infinity ' Infinity0 ' /td> ' Infinity0 ' ' Infinity ' ' infinity{} ' ' Infinity ' infinity ' Infinity ' nan nan ' Infinitynan ' ' Infinitya ' infinity infinity ' Infinity1 ' ' Infinity1 ' 1 " ' ' 1 ' ' 1{} ' ' 1 ' 1 ' 1 ' nan nan ' 1NaN ' ' 1a ' infinity 2 ' one ' ' one ' " "" ' 1 ' ' 1{} ' ' 1 ' ' 1undefined ' ' 1NaN ' ' 1a ' " " ' one ' ' ' ' ' 1 ' ' 1{} ' ' 1 ' ' 1undefined ' ' 1NaN ' ' 1a ' " " ' one '
 * 0 ' 0 ' [0] [] {} ' null [null] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' 0 ' 0 ' [0] [] {} ' NULL [NULL] undefined NaN [NaN] ' A ' Infinity 1 ' 1 ' [1] 0 0 0 0 nan 0 0 0 nan nan nan nan nan 0 0 0 0 0 0 0 nan 0 0 0 Span class= "number" >nan nan nan nan nan 0 0 0 0 0 0 nan 0 0 0 Span class= "number" >nan nan nan nan nan 0 0 0 0 0 0 nan 0 0 0 Span class= "number" >nan nan nan nan nan 0 0 nan nan nan nan nan Span class= "number" >nan nan nan nan nan nan nan nan nan nan 0 0 0 0 0 0 nan 0 0 0 Span class= "number" >nan nan nan nan nan 0 0 0 0 0 0 nan 0 0 0 Span class= "number" >nan nan nan nan nan 0 0 nan nan nan nan nan nan nan nan nan nan nan nan Span class= "number" >nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan infinity infinity infinity infinity 0 0 0 0 nan 0 0 0 nan nan nan nan infinity 1 1 1 0 0 0 0 nan 0 0 0 Span class= "number" >nan nan nan nan infinity 1 1 1 0 0 0 0 NaN 0 0 0 NaN NaN NaN NaN Infinity 1 1 1

Related Keywords:
Related Article

## E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

## Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

## Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth \$300-1200 USD