Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7586469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:26:16+00:00 2026-05-30T19:26:16+00:00

In most Node.js libraries people take special care removing trailing commas after the last

  • 0

In most Node.js libraries people take special care removing trailing commas after the last key-property pair of objects:

var test = {
    key1: 123,
    key2: 456,
    key3: 789
};

This produces some troubles while editing the code, e.g. to swap last two key-value pairs one has also to add one comma and to remove one. Some people move commas to the next line, which solves the issue with the last element but also makes the code a bit harder to read (IMHO):

var test = {
      key1: 123
    , key2: 456
    , key3: 789
};

On the other hand as far as I know the trailing commas in JavaScript produce troubles only in some IE browsers. So I’m wondering are there any technical reasons not to write hashes with trailing commas in Node.js? (Like the following:)

var test = {
    key1: 123,
    key2: 456,
    key3: 789,        
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:26:17+00:00Added an answer on May 30, 2026 at 7:26 pm

    No, there is no technical reason to do that.

    However, I never put trailing comas just because I think it makes for cleaner code. Probably some also have the habit coming from web development where, like you mentioned, you need to be careful about those because of IE.

    Edit: This answer made sense back in 2012, but today, with major browser support and tools like Babel for older browsers, I think trailing commas should be the default for everyone. The benefits are that it makes adding a new line easier, and the relevant Git diff is cleaner.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the most efficient way to go through and update every single node
Most people say never throw an exception out of a destructor - doing so
Can I find one XML node with the most children with XPath? <xml> <node
I'm making a Node.js app and I am using Winston for most of my
As most (all?) PHP libraries that do HTML sanitization such as HTML Purifier are
I'm trying to find the most elegant way for my node.js app to die
The most common theme I read about why to use node.js is for high
Given a n*n-sized multi-headed acyclic graph where each node has at most three children
binary tree, where each node has at most two child nodes, child nodes may
I used npm to install most of my dependent libraries. Now I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.