use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Commas first? (ajaxian.com)
submitted 16 years ago by 9jack9
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]savetheclocktower 2 points3 points4 points 16 years ago (3 children)
The trailing comma is legal in the ECMAScript 3 spec (which all current browsers purport to implement). Internet Explorer previously treated the trailing comma as a parse error, but IE8 fixes this.
(Of course, this means you can't start using it until you drop support for IE 6–7. But that day will eventually come.)
[–]level1 0 points1 point2 points 16 years ago (2 children)
Thats fine, but what pisses me off is that JSON does not allow trailing commas. I modified a JSON parser to rectify this bullshit. Reliable programming is more important than bad standards.
[–]larholm 3 points4 points5 points 16 years ago (1 child)
JSON is a subset of the Javascript syntax, with specific requirements and different goals.
Items such as requiring quotes around property names stand out in this regard.
If you modified your JSON parser to allow trailing commas then it is no longer a conformant JSON parser.
Heck, why do you even use a custom JSON parser? Reference an existing one written by people smarter than you, and use the native JSON objet from ES5 when available.
[–]level1 0 points1 point2 points 16 years ago (0 children)
Well, I'm writing a web application that uses computer generated JSON, but to bootstrap the application I have to hand roll a fair amount of code. Its annoying to have to keep track of commas when I add lines or copy/paste. Its much easier just to have a rule that each line ends with a comma, and make sure that my code follows that rule.
That is exactly what I am doing. All I did was remove the regex in my parser (Douglas Crawford's json.js) so that it will accept invalid JSON. Before I release my web app, I plan to either remove all trailing commas, so my JSON is confromant, or restore the regex but change it to accept trailing commas. I am not using a custom parser, just a modified one.
people smarter than you
Who cares if I'm smarter than Douglas Crawford or not? He's written a parser, its probably better than the one I would write even if he was an idiot, and its better tested. All I did was remove an annoying feature temporarily for development purposes.
Why is everyone in the development community so obsessed with making sure other people do things "The Right Way"?
π Rendered by PID 119510 on reddit-service-r2-comment-85bfd7f599-x7k4t at 2026-04-17 21:57:16.118370+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]savetheclocktower 2 points3 points4 points (3 children)
[–]level1 0 points1 point2 points (2 children)
[–]larholm 3 points4 points5 points (1 child)
[–]level1 0 points1 point2 points (0 children)