Update: I don’t follow this style anymore. I use semistandard


This is the javascript coding style I follow

  1. Comma first
  2. Two space indentation
  3. No semicolon
  4. Use single quotes

For example

var express = require('express')
  , User = mongoose.model('User')
  , auth = require('./authorization')
  , arr = [1, 2, 3, 4]

User
  .findOne({ name: 'abc' })
  .run(function (err, user) {
    if (err) return res.send(400)
    if (!user) {
      // do something
      return res.send(403)
    }
    res.json(user)
  })

Other styling guides out there:

  1. npm coding style
  2. Google javascript styling guide
  3. Github javascript styling guide
  4. idiomatic.js
  5. Felix’s node.js style guide

When I am developing on the server side (node.js) I don’t use semicolons, otherwise on the client side I mostly do.