Why do node packages put a comma on a newline?

Posted by SomeKittens on Programmers See other posts from Programmers or by SomeKittens
Published on 2012-11-10T23:38:25Z Indexed on 2012/11/11 5:21 UTC
Read the original article Hit count: 240

Filed under:
|
|

I'm learning node.js and am trying out Express. My first app had this code:

var express = require('express')
  , routes = require('./routes')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');

Reading through the mongoose tutorial gives me this:

var mongoose = require('mongoose')
  , db = mongoose.createConnection('localhost', 'test');

On strict mode, JSHint gives me

app.js: line 6, col 32, Bad line breaking before ','.

Which shows that I'm not the only one out there who's bugged by this syntax.

Is there any reason to declare vars this way instead of adding the comma at the end of the line?

© Programmers or respective owner

Related posts about JavaScript

Related posts about syntax