Skip to content

Javascript style guide

javisantana edited this page Jun 4, 2012 · 9 revisions

Javascript CartoDB style guide

this is the style guide for javascript in cartodb

naming

  • 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)

comments

every class or method should be commented. Ok. every class or method which is not clear should be commented

/**
 * this function executes whatevet
 * @param a blablablala
 * returns 0 if blwbla..
 */
function myFunction(a) {
}

misc

  • variable declaration:
var a,
    b, 
    c;
  • we use semicolons (use jslint or similar to check)
Clone this wiki locally