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?
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.
typeof nullproducingobjectwas 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 onnull === 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 isNaNand that's not a mistake, either. Just initially confusing.nullis unequivocably a primitive value: 262.ecma-international.org/11.0/… .typeofis just a strange operator.