-2

In the ECMAScript specs, it is clearly stated that Null is a type whose one and only value is null:

4.3.12 null value
primitive value that represents the intentional absence of any object value

4.3.13 Null type
type whose sole value is the null value

My question is very simple: why on earth we've got the below:

typeof null
>"object"

Is there any intent to correct/amend this? (either the specs or the JS language)

devio
  • 1,147
  • 5
  • 15
  • 41
  • `typeof` is different from the `Type()` operation in the language spec. Which e.g. doesn't distinguish callable objects (function) from non-callable objects. – Bergi Sep 15 '18 at 19:17

1 Answers1

3

JS does align with the ECMAScript spec. null values may have a Null type, but that does not mean that typeof is supposed to return "null". You can see the spec behavior in section 12.5.5.1, which defines the runtime behavior of typeof, that Null-type objects return "object" from typeof.

loganfsmyth
  • 156,129
  • 30
  • 331
  • 251