Why does typeof(null) return "object", but you can't assign properties to it?

Viewed 2552

Bear with me here, I'm going to try something stupid.

When I evaluate typeof(null) in the console, I get "object", so logically, I should be able to assign properties to it, but null.foo = 42 gives TypeError: Cannot set property 'foo' of null.

Is Javascript just picky when it comes to which global objects are mutable?

3 Answers
Related