0

I have been looking for the answer and gone through articles where some says its bug in javascript and consoling it in browser gives object.If so then why (null === null) is true.can anyone give clear explanation regarding this?

3
  • What exactly do you think is a "bug"? Commented Jan 26, 2021 at 7:35
  • 1
    The answer is confusingly both yes and no. typeof null producing object was a mistake at the very start. However, since then it has been codified in the spec, so it's not behaviour as expected. That has no bearing on null === null, however - the two values are the same - it's the same missing value both times. If the spec said they shouldn't be equal then the equality holding up would be a problem. As it stands, the specs say the opposite. The only value not equal to itself is NaN and that's not a mistake, either. Just initially confusing. Commented Jan 26, 2021 at 7:43
  • null is unequivocably a primitive value: 262.ecma-international.org/11.0/… . typeof is just a strange operator. Commented Jan 26, 2021 at 8:02

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.