Inconsistency with null
waldron.rick at gmail.com
Sun May 11 20:56:00 PDT 2014
On Sun, May 11, 2014 at 11:43 PM, Sakthipriyan Vairamani <
sakthiprofessional at gmail.com> wrote:
> console.log(typeof null);
> # object
> [object Null]
> This means that null
> is expected to be an object. But,
> # TypeError: Object.keys called on non-object
> The error message says that null
> is a non-object. It contradicts the result of typeof and toString.
This has been discussed extensively on this list over many years. Here is
the last relevant strawman proposal:
The TL;DR: typeof null is not going to change because it's too much of
> *Question 1:* Why does it behave so? Is this something which has to be
> Also, null is not a keyword <http://es5.github.io/#x220.127.116.11>, but when I
> var null = 1;
> # SyntaxError: Unexpected token null
> It fails with the Syntax Error, since it is a Reserved Word<http://es5.github.io/#x7.6.1>
> *Question 2:* What is the purpose of keeping null and boolean literals as
> "Reserved words" and not just keywords?
I apologize for answering this with another question, but what would the be
the point in changing them to keywords?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss