Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does NodeJS prefer the comma-first coding style?

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.

like image 398
jamjam Avatar asked Jun 16 '12 17:06

jamjam


1 Answers

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

like image 90
Madara's Ghost Avatar answered Oct 20 '22 20:10

Madara's Ghost