Just remember : the type of the value null should be normally null, but it's not !
typeofnull// --> "object"
It's a very interesting story about a little bug insidiously introduced at the very beginning of the JS implementation (a tiny neglected of an if statement fot this type !) described here, and will never be fixed (too late !).
However, this tale highly helps me remember the case !
In Gwion, I actually implemented @null type (the type of null) as inheriting from Object, as it means absence of an object. It's true this way needs a few special rules to match, say, function pointers but it works well this way.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
You know you can find the type of a value with the
typeof
command :Just remember : the type of the value
null
should be normallynull
, but it's not !It's a very interesting story about a little bug insidiously introduced at the very beginning of the JS implementation (a tiny neglected of an
if
statement fot this type !) described here, and will never be fixed (too late !).However, this tale highly helps me remember the case !
In Gwion, I actually implemented
@null
type (the type ofnull
) as inheriting fromObject
, as it means absence of an object. It's true this way needs a few special rules to match, say, function pointers but it works well this way.