TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Damncomma.js - because we all hate that damn comma...

1 pointsby exrationeabout 14 years ago

1 comment

exrationeabout 14 years ago
Because we all hate that damn comma... What is the Damn Comma?<p>[ "a", "b", // &#60;---- this is! ]<p>{ x: "x", y: "y", // &#60;---- so is this! }<p>If you came to Javascript from PHP or Python, you no doubt feel much as I do about the damn comma. So here is a quick hack to make you feel that much better about life.<p>How Does it Work?<p>By introducing a little trivial preprocessing into require() and JSON.parse() to smooth away the damn commas. See /example for usage.<p>Why Would I Even Use This?<p>Because you enjoy losing an annoying language feature and gaining the nebulous uncertainty that comes with introducing possibly deep and unexpected bugs. After all, who doesn't enjoy preprocessing the source code before it goes anywhere near a compiler or interpreter, such that it bears no semblance to what was written? Why, some of the most successful languages in history are practically built on that foundation - you'll be standing on the shoulders of giants!