On Mon, May 12, 2014 at 12:06 AM, Sakthipriyan Vairamani < [email protected]> wrote:
> Rick, > > Thanks for that URL. I will read that :-) > > Regarding the second question, why do we even need something called > reserved word? Reserved for what? Will it change in the future? If it is > accepted in the mainstream usage, why to keep that as reserved? > There are several definitions for the word "reserve"; this is the one used by ECMAScript: https://en.wikipedia.org/wiki/Reserved_word ie. "reserved from use". That article also describes the different between a reserved word and a keyword. Rick > - Thanks and Regards, > > *Sakthipriyan* > > > On Mon, May 12, 2014 at 3:56 AM, Rick Waldron <[email protected]>wrote: > >> On Sun, May 11, 2014 at 11:43 PM, Sakthipriyan Vairamani < >> [email protected]> wrote: >> >>> console.log(typeof null); >>> # object >>> >>> console.log(Object.prototype.toString.call(null)); >>> # >>> [object Null] >>> >>> >>> This means that null >>> is expected to be an object. But, >>> >> >>> >>> console.log(Object.keys(null)); >>> >>> # 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: >> http://wiki.ecmascript.org/doku.php?id=harmony:typeof_null >> >> The TL;DR: typeof null is not going to change because it's too much of >> web-breaking risk. >> >> >>> >>> *Question 1:* Why does it behave so? Is this something which has to be >>> fixed? >>> >> >> No. >> >> >>> >>> Also, null is not a keyword <http://es5.github.io/#x7.6.1.1>, but when >>> I do >>> >>> >>> 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? >> >> Rick >> >> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

