G
Garrett Smith
In doing research on JSON, I performed a search for `JSON undefined in
IE8`, I came upon familiar blog and found the entry had some information
that jumped out as being wrong.
I decided to leave a comment, but coming back several days later, I
found the comment was not approved. I emailed the author but I got no reply.
I saw the author is on Twitter, posting various things, so it is not as
if he is too busy. I sent a message on twitter, too:
http://twitter.com/dhtmlkitchen/status/16364046076
He did not reply, but posted another tweet right away:
http://twitter.com/slicknet/status/16364630527
I'm annoyed by both the misinformation and the censorship of a perfectly
well-intentioned reply.
I actually saved my comments in a file. Just in case.
| Internet Explorer 8’s JScript engine implements the native JSON
| object object as defined by ECMAScript 5. The object is only present,
| however, when the page is running in IE8 document mode. This includes
| the global JSON object as well as methods used for JSON functionality:
|
| * Date.prototype.toJSON()
| * Number.prototype.toJSON()
| * String.prototype.toJSON()
| * Boolean.prototype.toJSON()
Wrong! Only Date.prototype.toJSON is defined in ES5 and a simple:
alert(true.toJSON) shows that it's not in IE8, either.
The article then states:
| There’s a small group of fixes that can’t really be logically
| categorized but nonetheless help JScript come more into agreement
| with other JavaScript implementations. The first is that object
| literals now allow trailing commas. Prior to Internet Explorer 8, the
| following would cause a parse error:
|
| var object = {
| name: "value",
| };
|
|
| The trailing comma after the last property value is explicitly
| allowed by ECMAScript 3 syntax and is allowed in all other browsers.
| IE8 document mode now also supports this syntax correctly (other
| document modes still throw the error).
That's not true either. I explained in my comment that a trailing comma
in an ObjectLiteral is not provided for in the grammar of ECMAScript Ed.
3, that it is allowed in Ed 5, that its existence in Ed 5 is a
codification of existing behavior and that those are the reasons for IE8
allowing it.
But I noticed on the author's site:
| Note: Comments are heavily moderated. Please do not post spam. Please
| keep the comments on-topic. Please do not post unrelated questions or
| large chunks of code. Please be kind and keep the conversation civil
| and professional. Comments that are rude, off-topic, or don't have a
| valid email address are deleted.
My comment was not spam, was on-topic, and did not contain "large chunks
of code". It was civil and professional. I saved the comment to a file,
actually and so I can post it right here. I've only fixed one tiny typo
and not changed anything else.
Here are my unapproved comments:
| <blockquote>
| The trailing comma after the last property value is explicitly
| allowed by ECMAScript 3 syntax and is allowed in all other browsers.
| IE8 document mode now also supports this syntax correctly (other
| document modes still throw the error).
| </blockquote>
|
| That's not true. Trailing comma is not explicitly allowed by
| ECMAScript 3 syntax.
|
| <blockquote>
| <code>
| ObjectLiteral :
| {}
| { PropertyNameAndValueList }
|
| PropertyNameAndValueList :
| PropertyName : AssignmentExpression
| PropertyNameAndValueList , PropertyName : AssignmentExpression
| </code>
| </blockquote>
|
| That means you can have {} or { 1 : 2 } or { 1 : 2, 3 : 4 }, but none
| of { , } or {1 : 2, }or { , 3 : 4 }
|
| Trailing comma in object literal is allowed as a syntax extension.
| The production is also valid in ECMAScript Edition 5. You could call |
it a "codification". That fact, and that it works in other browsers,
| are probably the reasons why IE decided to implement it.
|
| You also wrote:
| <blockquote>
| Internet Explorer 8’s JScript engine implements the native JSON
| object object as defined by
| <a href="http://www.ecma-international.org
/publications/standards/Ecma-262.htm">ECMAScript 5</a>. The object is
| only present, however, when the page is running in IE8 document mode.
| This includes the global JSON object as well as methods used for JSON
| functionality:
|
| * Date.prototype.toJSON()
| * Number.prototype.toJSON()
| * String.prototype.toJSON()
| * Boolean.prototype.toJSON()
| </blockquote>
|
| Of that list, only Date.prototype.toJSON is defined. It looks like
| Luke Smith tried to say something to that effect, though I'm not
| quite sure.
|
| I know the spec can be tricky in some places and sometimes not fun to
| read, but those parts should not be too difficult. For example, try
| taking a look at the Boolean.prototype and you'll see
| Boolean.prototype.toString ( ) and Boolean.prototype.valueOf ( ).
| Boolean.prototype doesn't have a toJSON.
|
| http://www.ecma-international.org/publications/standards/Ecma-262.htm
That is what I posted, minus a small typo.
The false information on the blog remains.
Trying to impress less experienced developers with untested statements
is bad, but understandable. Publishing that online and trying to pass
that off as some form of helpful education is worse. Worse yet is
actively ignoring valid criticism. On some level, he must have
recognized that yes, the information posted was factually false.
Censoring the comment should have provided some indication that the
entry was not quite right, but there it remains, unchanged.
I get the sense that Nicholas Zakas lives in a small world of web
developers that are a lot less competent than he is and that he's not
used to being told when he is wrong.
A little social intelligence applied, he would have taken a civil high
road by owning the mistakes. Then again, he may very well have decided
that someone else pointing out a mistake was not considered
"constructive criticism" but "rude" and "off-topic".
Garrett
IE8`, I came upon familiar blog and found the entry had some information
that jumped out as being wrong.
I decided to leave a comment, but coming back several days later, I
found the comment was not approved. I emailed the author but I got no reply.
I saw the author is on Twitter, posting various things, so it is not as
if he is too busy. I sent a message on twitter, too:
http://twitter.com/dhtmlkitchen/status/16364046076
He did not reply, but posted another tweet right away:
http://twitter.com/slicknet/status/16364630527
I'm annoyed by both the misinformation and the censorship of a perfectly
well-intentioned reply.
I actually saved my comments in a file. Just in case.
| Internet Explorer 8’s JScript engine implements the native JSON
| object object as defined by ECMAScript 5. The object is only present,
| however, when the page is running in IE8 document mode. This includes
| the global JSON object as well as methods used for JSON functionality:
|
| * Date.prototype.toJSON()
| * Number.prototype.toJSON()
| * String.prototype.toJSON()
| * Boolean.prototype.toJSON()
Wrong! Only Date.prototype.toJSON is defined in ES5 and a simple:
alert(true.toJSON) shows that it's not in IE8, either.
The article then states:
| There’s a small group of fixes that can’t really be logically
| categorized but nonetheless help JScript come more into agreement
| with other JavaScript implementations. The first is that object
| literals now allow trailing commas. Prior to Internet Explorer 8, the
| following would cause a parse error:
|
| var object = {
| name: "value",
| };
|
|
| The trailing comma after the last property value is explicitly
| allowed by ECMAScript 3 syntax and is allowed in all other browsers.
| IE8 document mode now also supports this syntax correctly (other
| document modes still throw the error).
That's not true either. I explained in my comment that a trailing comma
in an ObjectLiteral is not provided for in the grammar of ECMAScript Ed.
3, that it is allowed in Ed 5, that its existence in Ed 5 is a
codification of existing behavior and that those are the reasons for IE8
allowing it.
But I noticed on the author's site:
| Note: Comments are heavily moderated. Please do not post spam. Please
| keep the comments on-topic. Please do not post unrelated questions or
| large chunks of code. Please be kind and keep the conversation civil
| and professional. Comments that are rude, off-topic, or don't have a
| valid email address are deleted.
My comment was not spam, was on-topic, and did not contain "large chunks
of code". It was civil and professional. I saved the comment to a file,
actually and so I can post it right here. I've only fixed one tiny typo
and not changed anything else.
Here are my unapproved comments:
| <blockquote>
| The trailing comma after the last property value is explicitly
| allowed by ECMAScript 3 syntax and is allowed in all other browsers.
| IE8 document mode now also supports this syntax correctly (other
| document modes still throw the error).
| </blockquote>
|
| That's not true. Trailing comma is not explicitly allowed by
| ECMAScript 3 syntax.
|
| <blockquote>
| <code>
| ObjectLiteral :
| {}
| { PropertyNameAndValueList }
|
| PropertyNameAndValueList :
| PropertyName : AssignmentExpression
| PropertyNameAndValueList , PropertyName : AssignmentExpression
| </code>
| </blockquote>
|
| That means you can have {} or { 1 : 2 } or { 1 : 2, 3 : 4 }, but none
| of { , } or {1 : 2, }or { , 3 : 4 }
|
| Trailing comma in object literal is allowed as a syntax extension.
| The production is also valid in ECMAScript Edition 5. You could call |
it a "codification". That fact, and that it works in other browsers,
| are probably the reasons why IE decided to implement it.
|
| You also wrote:
| <blockquote>
| Internet Explorer 8’s JScript engine implements the native JSON
| object object as defined by
| <a href="http://www.ecma-international.org
/publications/standards/Ecma-262.htm">ECMAScript 5</a>. The object is
| only present, however, when the page is running in IE8 document mode.
| This includes the global JSON object as well as methods used for JSON
| functionality:
|
| * Date.prototype.toJSON()
| * Number.prototype.toJSON()
| * String.prototype.toJSON()
| * Boolean.prototype.toJSON()
| </blockquote>
|
| Of that list, only Date.prototype.toJSON is defined. It looks like
| Luke Smith tried to say something to that effect, though I'm not
| quite sure.
|
| I know the spec can be tricky in some places and sometimes not fun to
| read, but those parts should not be too difficult. For example, try
| taking a look at the Boolean.prototype and you'll see
| Boolean.prototype.toString ( ) and Boolean.prototype.valueOf ( ).
| Boolean.prototype doesn't have a toJSON.
|
| http://www.ecma-international.org/publications/standards/Ecma-262.htm
That is what I posted, minus a small typo.
The false information on the blog remains.
Trying to impress less experienced developers with untested statements
is bad, but understandable. Publishing that online and trying to pass
that off as some form of helpful education is worse. Worse yet is
actively ignoring valid criticism. On some level, he must have
recognized that yes, the information posted was factually false.
Censoring the comment should have provided some indication that the
entry was not quite right, but there it remains, unchanged.
I get the sense that Nicholas Zakas lives in a small world of web
developers that are a lot less competent than he is and that he's not
used to being told when he is wrong.
A little social intelligence applied, he would have taken a civil high
road by owning the mistakes. Then again, he may very well have decided
that someone else pointing out a mistake was not considered
"constructive criticism" but "rude" and "off-topic".
Garrett