"# node-test-server"
Variables, properties and function names should use lowerCamelCase
. They
should also be descriptive. Single character variables and uncommon
abbreviations should generally be avoided.
Right:
var adminUser = db.query('SELECT * FROM users ...');
Wrong:
var admin_user = db.query('SELECT * FROM users ...');
Class names should be capitalized using UpperCamelCase
.
Right:
function BankAccount() {
}
Wrong:
function bank_Account() {
}
Constants should be declared as regular variables or static class properties, using all uppercase letters.
Right:
var SECOND = 1 * 1000;
function File() {
}
File.FULL_PERMISSIONS = 0777;
Wrong:
const SECOND = 1 * 1000;
function File() {
}
File.fullPermissions = 0777;
Use trailing commas and put short declarations on a single line. Only quote keys when your interpreter complains:
Right:
var a = ['hello', 'world'];
var b = {
good: 'code',
'is generally': 'pretty',
};
Wrong:
var a = [
'hello', 'world'
];
var b = {"good": 'code'
, is generally: 'pretty'
};