The type of null
david.bruant at labri.fr
Sun Sep 4 08:04:49 PDT 2011
Le 04/09/2011 14:31, Xavier MONTILLET a écrit :
> I saw in the spec that null is a litteral but typeof null must return 'object'.
There are two things that are different. One is the Null type as defined
in ES5.1 section 8.2 and the return value of "typeof null" ('object').
This is a notorious spec bug and is very likely to be fixed in the next
version of ECMAScript (see
> So I was wondering:
> Is Object.isExtensible(null) supposed to trow an error or to return false?
Step 1 of Object.isExtensible is "If Type(O) is not Object throw a
TypeError exception.". Here, "Type(O)" refers to the type defined in
ES5.1 section 8. Consequently, Type(null) is Null (8.2) which is not
Object: "Object.isExtensible(null)" is supposed to throw a TypeError
(and does properly in Firefox 6 as I have just tested).
Another notable difference between ECMAScript types and typeof is
functions. There is no ECMAScript Function type. Functions are Objects
with an internal [[Call]] property (see ES5.1 - 11.4.3 table 20) and for
them, the typeof operator returns "function".
More information about the es-discuss