Home » Nodejs » Why does NodeJS prefer the comma-first coding style?

Why does NodeJS prefer the comma-first coding style?

Posted by: admin November 29, 2017 Leave a comment

Questions:

I have been learning NodeJS recently.

It seems to be standard in the Node world to write code with commas first:

var connect = require('connect')
  , HTTPSServer = require('./https')
  , HTTPServer = require('./http')
  , Route = require('./router/route')

I don’t like it and my code editor via JSLint throws countless errors.

My question is: is there a justifiable reason why “nodesters” are doing this or is it just a cool new style?

Until now I have been “correcting” it by putting the commas back “where they should be” to comply with JSLint.

But it occurred to me recently that this approach is not very sustainable, especially if I am going to make use of more community modules.

Answers:

Generally, it makes for cleaner looking code (subjective), and easy spotting of errors. Happy reading