Sometimes, it has been questioned whether it was wise to
implement
typeof null
"object"
. However, I just became aware that this is echoing a
similar case:
typeof NaN
"number"
. NaN says its »Not a Number«, yet typeof says it is a
number!
It seems that sometimes people want an in »in band«
»non-value« to mark to lack of a »real value«. The value
must be »in band«, that is, it must be allowed where a value
is expected. Yet, it must then contain the information that
it is /not/ a real value. Similar with »NULL« in SQL or
»void« as a »type« in C.
A clean solution would be to always distinguish between
entities and meta-entities. For example: »0, 1, 2, ...« are
numbers, and »NaN, 0, 1, 2, ...« are meta-numbers. (This
distinction does not have to be implemented, but could be
used in descriptions of a programming language.) But people
also often do not want to use too many different words, even
if they have to pay the price of actual contradictions.
In JavaScript, we could even have:
meta-meta-objects
/ / / / / \
/ \
/ \
/ \
undefined meta-objects
/ / / / / \
/ \
/ \
/ \
null objects