B
B
bormor2018-04-11 11:30:28
JavaScript
bormor, 2018-04-11 11:30:28

js type conversion. Why 0 == null // false?

It would seem that
'==' starts casting to a number, i.e.
0 == null
Number(0) == Number(null)
0 === 0
true
In fact
0 == null //false
Why is that? How does it go through the steps?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bormor, 2018-04-11
@bormor

"Null and undefined are equal == to each other and are not equal to anything else. This hard and fast rule is literally written into the language specification." I. Kantor

V
VoidVolker, 2018-04-11
@VoidVolker

Because those are the specifications of the language. Here is the full table: https://dorey.github.io/JavaScript-Equality-Table/
And don't duplicate questions, please - read the language specifications, everything is there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question