-
Notifications
You must be signed in to change notification settings - Fork 649
Javascript style guide
xavijam edited this page Jun 4, 2012
·
9 revisions
this is the style guide for javascript in cartodb
- GLOBALS_ARE_UPPERCASE_AND_UNDERSCORED
- local variables are as short as you can and camelCase
- use self to scope this
- function and method names are camelCase
- private methods start with underscore
- class names are CamelCase (capitalized)
every class or method should be commented. Ok. every class or method which is not clear should be commented
/**
* Illustrates line wrapping for long param/return descriptions.
* @param {string} foo This is a param with a description too long to fit in
* one line.
* @return {number} This returns something that has a description too long to
* fit in one line.
*/
function method(foo) {
return 5;
}
- variable declaration:
var a = 'a'
, b = null
, c;
- we use semicolons (use jslint or similar to check)