Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.
/ javascript Public archive
forked from airbnb/javascript

JavaScript Style Guide

Notifications You must be signed in to change notification settings

syapse/javascript

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

Syapse JavaScript Style Guide() {

A mostly reasonable approach to JavaScript

Table of Contents

  1. Objects
  2. Arrays
  3. Strings
  4. Functions
  5. Properties
  6. Variables
  7. Hoisting
  8. Conditional Expressions & Equality
  9. Blocks
  10. Comments
  11. Whitespace
  12. Commas
  13. Semicolons
  14. Type Casting & Coercion
  15. Naming Conventions
  16. Accessors
  17. Constructors
  18. Events
  19. Modules
  20. Require
  21. jQuery
  22. ECMAScript 5 Compatibility
  23. Testing
  24. Performance
  25. Resources
  26. In the Wild
  27. Translation
  28. The JavaScript Style Guide Guide
  29. Contributors
  30. License

Objects

  • Use the literal syntax for object creation.

    // bad
    var item = new Object();
    
    // good
    var item = {};
  • Don't use un-quoted reserved words as keys. It won't work in ECMAScript 3 browsers (ie. IE9). More info

    // bad
    var superman = {
      default: { clark: 'kent' },
      private: true
    };
    
    // good
    var superman = {
      defaults: { clark: 'kent' },
      hidden: true
    };
  • If possible, use readable synonyms in place of reserved words.

    // bad
    var superman = {
      class: 'alien'
    };
    
    // bad
    var superman = {
      klass: 'alien'
    };
    
    // good
    var superman = {
      type: 'alien'
    };

    If you must use a keyword as a key for some reason (eg. because a library or API expects it), quoting the key is allowed.

⬆ back to top

Arrays

  • Use the literal syntax for array creation

    // bad
    var items = new Array();
    
    // good
    var items = [];
  • If you don't know array length use Array#push.

    var someStack = [];
    
    
    // bad
    someStack[someStack.length] = 'abracadabra';
    
    // good
    someStack.push('abracadabra');
  • When you need to copy an array use Underscore's _.clone method.

    var len = items.length,
        itemsCopy = [],
        i;
    
    // bad
    for (i = 0; i < len; i++) {
      itemsCopy[i] = items[i];
    }
    
    // good
    itemsCopy = _(items).clone();
  • To convert an array-like object to an array, use Underscore's toArray method.

    function trigger() {
      var args = _.toArray(arguments);
      ...
    }

    Note: This should mainly be used to convert arguments; converting other types (eg. strings) may have unexpected results.

⬆ back to top

Strings

  • Always yse single quotes '' for strings, unless you have a literal string with asingle-quote inside it. In that case, the developer may choose to escape the single quote, or they may opt to use double-quotes, at their discretion.

    // bad
    var name = "Bob Parr";
    
    // good
    var name = 'Bob Parr';
    
    // bad
    var fullName = "Bob " + this.lastName;
    
    // good
    var fullName = 'Bob ' + this.lastName;
  • String literals which cause their line to exceed 100 characters should be written across multiple lines using string concatenation.

  • Note: If overused, long strings with concatenation could impact performance. jsPerf & Discussion

    // bad
    var errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
    
    // bad
    var errorMessage = 'This is a super long error that was thrown because \
    of Batman. When you stop to think about how Batman had anything to do \
    with this, you would get nowhere \
    fast.';
    
    // good
    var errorMessage = 'This is a super long error that was thrown because ' +
      'of Batman. When you stop to think about how Batman had anything to do ' +
      'with this, you would get nowhere fast.';
  • If you need to concatenate multiple strings you can either use the + operator or the join method (whichever, in the developer's opinion, would be more readable).

  • Particularly long strings should not be put in the Javascript code at all; instead they should be stored in a separate text file and brought in via Require.js.

⬆ back to top

Functions

  • All functions should be declared as variables, both for readability and to avoid hoisting issues (as well as to reinforce the notion that functions are first-class objects).

    // bad
    function foo() { ... }
    
    // good
    var foo = function() { ... };
  • Function expressions:

    // anonymous function expression
    var anonymous = function() {
      return true;
    };
    
    // named function expression
    var named = function named() {
      return true;
    };
    
    // immediately-invoked function expression (IIFE)
    (function() {
      console.log('Welcome to the Internet. Please follow me.');
    })();
  • In general, named functions should be avoided, as they just add redundant information (eg. var foo = function foo() { ...);. However, named functions can be helpful when debugging, so it is acceptable to check in a named function expression in the rare case when a particular function is frequently involved in debugging.

  • Never declare a function in a looping block (for, while, etc), as this may be confusing.

    // bad
    for (var i = 0; i < 100; i++) {
      function test() {
        console.log('Nope.');
      }
    }
  • Never name a parameter arguments, this will take precedence over the arguments object that is given to every function scope.

    // bad
    function nope(name, options, arguments) {
      // ...stuff...
    }
    
    // good
    function yup(name, options, args) {
      // ...stuff...
    }

⬆ back to top

Properties

  • Use dot notation whenever possible.

    var luke = {
      jedi: true,
      age: 28
    };
    
    // bad
    var isJedi = luke['jedi'];
    
    // good
    var isJedi = luke.jedi;
  • Use subscript notation [] only when the key can not be expressed using dot notation (eg. 'foo-bar') or when accessing properties using a variable.

    var luke = {
      jedi: true,
      age: 28
    };
    
    function getProp(prop) {
      return luke[prop];
    }
    
    var isJedi = getProp('jedi');

⬆ back to top

Variables

  • Always use var to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that.

    // bad
    superPower = new SuperPower();
    
    // good
    var superPower = new SuperPower();
  • Developers may choose to use one var declaration or multiple var declarations for multiple variables, as they see fit. Multiple var statements makes it easier to intersperse debugger statements in between, but if several variables are concepually linked the readability benefit of declaring them altogether in a single var statement may outweight the ability to easily add debugger statements.

    // bad
    var items = getItems();
    var goSportsTeam = true;
    var dragonball = 'z';
    
    // good
    var items = getItems(),
        goSportsTeam = true,
        dragonball = 'z';
  • Variables should be grouped by concept first, and then within groupings unassigned variables should be declared last. This is helpful when later on you might need to assign a variable depending on one of the previous assigned variables.

    // bad
    var i, len, dragonball,
        items = getItems(),
        goSportsTeam = true;
    
    // bad
    var i, items = getItems(),
        dragonball,
        goSportsTeam = true,
        len;
    
    // good
    var items = getItems(),
        goSportsTeam = true,
        dragonball,
        length,
        i;
  • Assign variables when they first get used, or whenever the developer feels it would be most clear to define them; variables do not need to be declared at the top of their scope.

⬆ back to top

Blocks

  • Use braces with all multi-line blocks.

    // bad
    if (test)
      return false;
    
    // good
    if (test) return false;
    
    // good
    if (test) {
      return false;
    }
    
    // bad
    function() { return false; }
    
    // good
    function() {
      return false;
    }

⬆ back to top

Comments

  • Use /** ... */ for multiline comments. Include a description, specify types and values for all parameters and return values.

  • NOTE: The developer may choose, at their option, top not include the leading asterisks on each line, as technically this is allowed by the JSDoc standard.

    // bad
    // make() returns a new element
    // based on the passed in tag name
    //
    // @param <String> tag
    // @return <Element> element
    function make(tag) {
    
      // ...stuff...
    
      return element;
    }
    
    // good
    /**
     * make() returns a new element
     * based on the passed in tag name
     *
     * @param <String> tag
     * @return <Element> element
     */
    function make(tag) {
    
      // ...stuff...
    
      return element;
    }
    
    // also acceptable
    /**
     make() returns a new element
     based on the passed in tag name
     @param <String> tag
     @return <Element> element
     */
    function make(tag) {
    
      // ...stuff...
    
      return element;
    }
    
  • Use // for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment.

    // bad
    var active = true;  // is current tab
    
    // good
    // is current tab
    var active = true;
    
    // bad
    function getType() {
      console.log('fetching type...');
      // set the default type to 'no type'
      var type = this._type || 'no type';
    
      return type;
    }
    
    // good
    function getType() {
      console.log('fetching type...');
    
      // set the default type to 'no type'
      var type = this._type || 'no type';
    
      return type;
    }
  • Prefixing your comments with FIXME or TODO helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are FIXME -- need to figure this out or TODO -- need to implement.

  • Use // FIXME: to annotate problems

    function Calculator() {
    
      // FIXME: shouldn't use a global here
      total = 0;
    
      return this;
    }
  • Use // TODO: to annotate solutions to problems

    function Calculator() {
    
      // TODO: total should be configurable by an options param
      this.total = 0;
    
      return this;
    }

**[⬆ back to top](#table-of-contents)**


## Whitespace

- Use soft tabs set to 4 spaces

  ```javascript
  // bad
  function() {
  ∙∙var name;
  }

  // bad
  function() {
  ∙var name;
  }

  // good
  function() {
  ∙∙∙∙var name;
  }
  ```

- Place 1 space before the leading brace.

  ```javascript
  // bad
  function test(){
    console.log('test');
  }

  // good
  function test() {
    console.log('test');
  }

  // bad
  dog.set('attr',{
    age: '1 year',
    breed: 'Bernese Mountain Dog'
  });

  // good
  dog.set('attr', {
    age: '1 year',
    breed: 'Bernese Mountain Dog'
  });
  ```

- Set off operators with spaces.

  ```javascript
  // bad
  var x=y+5;

  // good
  var x = y + 5;
  ```

- End files with either a single or a double newline character (it doesn't matter which).

- Break long method chains up in to multiple lines, using one of two styles:

  ```javascript
  // bad
  $('#items').find('.selected').highlight().updateCount();

  // good
  $('#items')
      .find('.selected')
      .highlight()
      .updateCount();

  // also good
  $('#items').find('.selected')
             .highlight()
             .updateCount();
  ```

- Keep in mind that readability is paramount, so if the second format results in excessively indented code, refactor it to use a variable:

  ```javascript
  // bad
  $('#realllyLongIdOfAnElement .reallyLongClassNameForAnElement').find('.selected')
                                                                 .highlight()
                                                                 .updateCount();
                                                                 
  // good
  var $long = ('#realllyLongIdOfAnElement .reallyLongClassNameForAnElement')
  $long.find('.selected')
       .highlight()
       .updateCount();
  ```

**[⬆ back to top](#table-of-contents)**

## Commas

- Leading commas: **Nope.**

  ```javascript
  // bad
  var once
    , upon
    , aTime;

  // good
  var once,
      upon,
      aTime;

  // bad
  var hero = {
      firstName: 'Bob'
    , lastName: 'Parr'
    , heroName: 'Mr. Incredible'
    , superPower: 'strength'
  };

  // good
  var hero = {
    firstName: 'Bob',
    lastName: 'Parr',
    heroName: 'Mr. Incredible',
    superPower: 'strength'
  };
  ```

- Additional trailing comma: **Optional.** Although a trailing comma can cause problems with older Internet Explorers, the Require Optimizer takes care of eliminating these for us. Developers debugging (older) Internet Explorer-specific issues should temporarily switch to using the optimized files instead of the original source files.

**[⬆ back to top](#table-of-contents)**



## Semicolons

- **Yup.**

  ```javascript
  // bad
  (function() {
    var name = 'Skywalker'
    return name
  })()

  // good
  (function() {
    var name = 'Skywalker';
    return name;
  })();
  ```

- Leading with a semi-colon when using the module pattern is acceptable ... but under normal circumstances we should never have any need to use the module pattern (as we use Require's module system).

  ```javascript
  // good (guards against the function becoming an argument when two files with IIFEs are concatenated)
  ;(function() {
    var name = 'Skywalker';
    return name;
  })();
  ```

  [Read more](https://stackoverflow.com/a/7365214/1712802).

**[⬆ back to top](#table-of-contents)**


## Type Casting & Coercion

- If you are adding two variables together, and have no idea what type the second variable will have, then it is safer to start with the variable whose type you know (ie. perform type coercion at the beginning of the statement). However, if you know the types of both variables (as should almost always be the case), then you can put them in any order. Syapse has no requirement on which order to add variables, and expects developers to understand the language's type coercion and program appropriately.

- Strings:

  ```javascript
  //  => this.reviewScore = 9;

  // good (as long as you know this.reviewScore is a string)
  var totalScore = this.reviewScore + '';

  // also good
  var totalScore = '' + this.reviewScore;
  ```

- Use `parseInt` for Numbers and always with a radix for type casting. While using `Number(inputValue)` will also work, it's simpler to have all Syapse developers use the same mechanism for coercing strings to integers (and that mechanism has historically always been parseInt).

  ```javascript
  var inputValue = '4';

  // bad
  var val = new Number(inputValue);

  // bad
  var val = +inputValue;

  // bad
  var val = inputValue >> 0;

  // bad
  var val = parseInt(inputValue);

  // bad (it works, but departs from our convention of using parseInt with no benefit)
  var val = Number(inputValue);

  // good
  var val = parseInt(inputValue, 10);
  ```

- Do not use bitshifting to parse numbers.  If parseInt ever becomes a performance bottleneck (which is very unlikely) we can always revisit this rule, but for now using bitshifting is considered to be unecessary obfuscation of the code.

- Booleans:

  ```javascript
  var age = 0;

  // bad
  var hasAge = new Boolean(age);

  // bad (again, it will work, but goes against Syapse convention)
  var hasAge = Boolean(age);

  // good
  var hasAge = !!age;
  ```

**[⬆ back to top](#table-of-contents)**


## Naming Conventions

- Avoid single letter or abbreviated (eg. "tmplt" instead of "template") names. Be descriptive with your naming.

  ```javascript
  // bad
  function q() {
    // ...stuff...
  }

  // good
  function query() {
    // ..stuff..
  }
  ```

- An exception to the above rule is single-character variable names that are an industry-wide convention. Specifically:
  * `e` - can be used as the first argument of an event handling function
  * `i`, `j`, `k`, etc. - can be used as the name of the counter inside a `for` loop (on the rare occaisions when we use `for` loops instead of `_.each` or a similar Underscore iterative function).

- Use camelCase when naming objects, functions, and instances

  ```javascript
  // bad
  var OBJEcttsssss = {};
  var this_is_my_object = {};
  function c() {}
  var u = new user({
    name: 'Bob Parr'
  });

  // good
  var thisIsMyObject = {};
  function thisIsMyFunction() {}
  var user = new User({
    name: 'Bob Parr'
  });
  ```

- Use PascalCase when naming constructors or classes

  ```javascript
  // bad
  function user(options) {
    this.name = options.name;
  }

  var bad = new user({
    name: 'nope'
  });

  // good
  function User(options) {
    this.name = options.name;
  }

  var good = new User({
    name: 'yup'
  });
  ```

- Use a leading underscore `_` when naming private properties

  ```javascript
  // bad
  this.__firstName__ = 'Panda';
  this.firstName_ = 'Panda';

  // good
  this._firstName = 'Panda';
  ```

- NOTE: As a general practice developers should be strongly biased towards creating private methods. It's easy to change a private method to a public one (you just remove the "_") but converting in the other direction (public => private) is significantly harder (you have to search the entire codebase to find any out-of-class references to the method before it can be made private).

- When saving a reference to `this` use `self` ... although most of the time you should never need to use `self` as you can simply use `_.bind`, `done2`, etc. to pass the context without the need for an extra variable.

  ```javascript
  // bad
  function() {
    var _this = this;
    return function() {
      console.log(_this);
    };
  }

  // bad
  function() {
    var that = this;
    return function() {
      console.log(that);
    };
  }

  // good
  function() {
    var self = this;
    return function() {
      console.log(self);
    };
  }
  
  // better
  function() {
    return _(function() {
      console.log(_this);
    }).bind(this);
  }
  ```

- Developers may choose to name their functions or not. While this practice can be helpful when debugging, thanks to improvements in the Chrome Debugger explicit function names are mostly unecessary, and let's face it: typing a function's name twice is annoying. At the same time if you do need to add a function name for debugging, there's nothing wrong with leaving it in the code afterward.

  ```javascript
  // good
  var log = function(msg) {
    console.log(msg);
  };

  // good
  var log = function log(msg) {
    console.log(msg);
  };
  ```

- **Note:** IE8 and below exhibit some quirks with named function expressions.  See [https://kangax.github.io/nfe/](https://kangax.github.io/nfe/) for more info.

**[⬆ back to top](#table-of-contents)**


## Accessors

- Accessor functions for properties are not required
- If you do make accessor functions use getVal() and setVal('hello')

  ```javascript
  // bad
  dragon.age();

  // good
  dragon.getAge();

  // bad
  dragon.age(25);

  // good
  dragon.setAge(25);
  ```

- If the property is a boolean, use isVal() or hasVal()

  ```javascript
  // bad
  if (!dragon.age()) {
    return false;
  }

  // good
  if (!dragon.hasAge()) {
    return false;
  }
  ```

**[⬆ back to top](#table-of-contents)**


## Constructors


- Methods in general should not return `this` to enable "chaining."  There are two exceptions to this rule:
* `render` methods (because of both Backbone and Syapse conventions, all `render` methods should return `this`; this gives the invoker of `render` the option to use `render().el` or `render().$el`)
* Chaining is acceptable if used only within a single class, in methods that have been specifically designed to be chained. Syapse does not currently have such a class, but both jQuery and Sinon provide examples of how this approach could be valuable, and one could certainly imagine a future class that could benefit (eg. a SyQlBuilder class that uses chained methods for adding statements).

  ```javascript
  // good
  Backbone.View.extend({
      jump: function() {
        this.jumping = true;
        return true;
      };
  });

  // discouraged
  Backbone.View.extend({
      jump: function() {
        this.jumping = true;
        return this;
      };
  });
  
  // good
  Backbone.View.extend({
      render: function() {
        this.jumping = true;
        return true;
      };
  });
  ```


- It's okay to write a custom toString() method, just make sure it works successfully and causes no side effects.

  ```javascript
  function Jedi(options) {
    options || (options = {});
    this.name = options.name || 'no name';
  }

  Jedi.prototype.getName = function getName() {
    return this.name;
  };

  Jedi.prototype.toString = function toString() {
    return 'Jedi - ' + this.getName();
  };
  ```

**[⬆ back to top](#table-of-contents)**

## Events

- When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of:

  ```js
  // bad
  $(this).trigger('listingUpdated', listing.id);

  ...

  $(this).on('listingUpdated', function(e, listingId) {
    // do something with listingId
  });
  ```

  prefer:

  ```js
  // good
  $(this).trigger('listingUpdated', { listingId : listing.id });

  ...

  $(this).on('listingUpdated', function(e, data) {
    // do something with data.listingId
  });
  ```

**[⬆ back to top](#table-of-contents)**

*RULES BELOW THIS POINT ARE NOT PART OF SYAPSE'S FORMATTING GUIDELINES*
*(please consider them to be under consideration)*

## Modules

- The module should start with a `!`. This ensures that if a malformed module forgets to include a final semicolon there aren't errors in production when the scripts get concatenated. [Explanation](https://github.com/airbnb/javascript/issues/44#issuecomment-13063933)
- The file should be named with camelCase, live in a folder with the same name, and match the name of the single export.
- Add a method called `noConflict()` that sets the exported module to the previous version and returns this one.
- Always declare `'use strict';` at the top of the module.

  ```javascript
  // fancyInput/fancyInput.js

  !function(global) {
    'use strict';

    var previousFancyInput = global.FancyInput;

    function FancyInput(options) {
      this.options = options || {};
    }

    FancyInput.noConflict = function noConflict() {
      global.FancyInput = previousFancyInput;
      return FancyInput;
    };

    global.FancyInput = FancyInput;
  }(this);
  ```

**[⬆ back to top](#table-of-contents)**

## Require

- All dependencies should be defined inside a `define` statement when at all possible, NOT as part of an inline (single-argument) `require` statement. However, certain modules need to be brought in via an inline `require` (eg. `routerInstance`) because they cannot be brought in through a `define` without creating a circular dependency. For these modules it is acceptable to use an inline `require`.
- To help ensure that we are not adding inline `require` statements unecessarily, all code reviews should endeavor to find non-inline `require` alternatives to any inline `require` statements in the reviewed code.

**[⬆ back to top](#table-of-contents)**

## jQuery

- Prefix jQuery object variables with a `$`.

  ```javascript
  // bad
  var sidebar = $('.sidebar');

  // good
  var $sidebar = $('.sidebar');
  ```

- Cache jQuery lookups.

  ```javascript
  // bad
  function setSidebar() {
    $('.sidebar').hide();

    // ...stuff...

    $('.sidebar').css({
      'background-color': 'pink'
    });
  }

  // good
  function setSidebar() {
    var $sidebar = $('.sidebar');
    $sidebar.hide();

    // ...stuff...

    $sidebar.css({
      'background-color': 'pink'
    });
  }
  ```

- For DOM queries use Cascading `$('.sidebar ul')` or parent > child `$('.sidebar > ul')`. [jsPerf](https://jsperf.com/jquery-find-vs-context-sel/16)
- Use `find` with scoped jQuery object queries.

  ```javascript
  // bad
  $('ul', '.sidebar').hide();

  // bad
  $('.sidebar').find('ul').hide();

  // good
  $('.sidebar ul').hide();

  // good
  $('.sidebar > ul').hide();

  // good
  $sidebar.find('ul').hide();
  ```
- Never affect more than one element in a single jQuery statement, as this makes the code less readable.  Instead, break the statement up in to multiple statements

  ```javascript
  // bad
  $('#foo').find('ul').hide().find('li').addClass('hidden');
 
  // good
  var $foo = $('#foo');
  $foo.find('ul').hide();
  $foo.find('ul li').addClass('hidden');
  ```


**[⬆ back to top](#table-of-contents)**


## ECMAScript 5 Compatibility

- Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](https://kangax.github.com/es5-compat-table/)

**[⬆ back to top](#table-of-contents)**


## Testing

- **Yup.**

  ```javascript
  function() {
    return true;
  }
  ```

**[⬆ back to top](#table-of-contents)**


## Performance

- [On Layout & Web Performance](https://kellegous.com/j/2013/01/26/layout-performance/)
- [String vs Array Concat](https://jsperf.com/string-vs-array-concat/2)
- [Try/Catch Cost In a Loop](https://jsperf.com/try-catch-in-loop-cost)
- [Bang Function](https://jsperf.com/bang-function)
- [jQuery Find vs Context, Selector](https://jsperf.com/jquery-find-vs-context-sel/13)
- [innerHTML vs textContent for script text](https://jsperf.com/innerhtml-vs-textcontent-for-script-text)
- [Long String Concatenation](https://jsperf.com/ya-string-concat)
- Loading...

**[⬆ back to top](#table-of-contents)**


## Resources


**Read This**

- [Annotated ECMAScript 5.1](https://es5.github.com/)

**Other Styleguides**

- [Google JavaScript Style Guide](https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml)
- [jQuery Core Style Guidelines](https://docs.jquery.com/JQuery_Core_Style_Guidelines)
- [Principles of Writing Consistent, Idiomatic JavaScript](https://github.com/rwldrn/idiomatic.js/)

**Other Styles**

- [Naming this in nested functions](https://gist.github.com/4135065) - Christian Johansen
- [Conditional Callbacks](https://github.com/airbnb/javascript/issues/52)
- [Popular JavaScript Coding Conventions on Github](https://sideeffect.kr/popularconvention/#javascript)

**Further Reading**

- [Understanding JavaScript Closures](https://javascriptweblog.wordpress.com/2010/10/25/understanding-javascript-closures/) - Angus Croll
- [Basic JavaScript for the impatient programmer](https://www.2ality.com/2013/06/basic-javascript.html) - Dr. Axel Rauschmayer
- [You Might Not Need jQuery](https://youmightnotneedjquery.com/) - Zack Bloom & Adam Schwartz
- [ES6 Features](https://github.com/lukehoban/es6features) - Luke Hoban

**Books**

- [JavaScript: The Good Parts](https://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742) - Douglas Crockford
- [JavaScript Patterns](https://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752) - Stoyan Stefanov
- [Pro JavaScript Design Patterns](https://www.amazon.com/JavaScript-Design-Patterns-Recipes-Problem-Solution/dp/159059908X)  - Ross Harmes and Dustin Diaz
- [High Performance Web Sites: Essential Knowledge for Front-End Engineers](https://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309) - Steve Souders
- [Maintainable JavaScript](https://www.amazon.com/Maintainable-JavaScript-Nicholas-C-Zakas/dp/1449327680) - Nicholas C. Zakas
- [JavaScript Web Applications](https://www.amazon.com/JavaScript-Web-Applications-Alex-MacCaw/dp/144930351X) - Alex MacCaw
- [Pro JavaScript Techniques](https://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273) - John Resig
- [Smashing Node.js: JavaScript Everywhere](https://www.amazon.com/Smashing-Node-js-JavaScript-Everywhere-Magazine/dp/1119962595) - Guillermo Rauch
- [Secrets of the JavaScript Ninja](https://www.amazon.com/Secrets-JavaScript-Ninja-John-Resig/dp/193398869X) - John Resig and Bear Bibeault
- [Human JavaScript](https://humanjavascript.com/) - Henrik Joreteg
- [Superhero.js](https://superherojs.com/) - Kim Joar Bekkelund, Mads Mobæk, & Olav Bjorkoy
- [JSBooks](https://jsbooks.revolunet.com/)
- [Third Party JavaScript](https://manning.com/vinegar/) - Ben Vinegar and Anton Kovalyov

**Blogs**

- [DailyJS](https://dailyjs.com/)
- [JavaScript Weekly](https://javascriptweekly.com/)
- [JavaScript, JavaScript...](https://javascriptweblog.wordpress.com/)
- [Bocoup Weblog](https://weblog.bocoup.com/)
- [Adequately Good](https://www.adequatelygood.com/)
- [NCZOnline](https://www.nczonline.net/)
- [Perfection Kills](https://perfectionkills.com/)
- [Ben Alman](https://benalman.com/)
- [Dmitry Baranovskiy](https://dmitry.baranovskiy.com/)
- [Dustin Diaz](https://dustindiaz.com/)
- [nettuts](https://net.tutsplus.com/?s=javascript)

**[⬆ back to top](#table-of-contents)**

## In the Wild

This is a list of organizations that are using this style guide. Send us a pull request or open an issue and we'll add you to the list.

- **Aan Zee**: [AanZee/javascript](https://github.com/AanZee/javascript)
- **Airbnb**: [airbnb/javascript](https://github.com/airbnb/javascript)
- **American Insitutes for Research**: [AIRAST/javascript](https://github.com/AIRAST/javascript)
- **Compass Learning**: [compasslearning/javascript-style-guide](https://github.com/compasslearning/javascript-style-guide)
- **DailyMotion**: [dailymotion/javascript](https://github.com/dailymotion/javascript)
- **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript)
- **ExactTarget**: [ExactTarget/javascript](https://github.com/ExactTarget/javascript)
- **Gawker Media**: [gawkermedia/javascript](https://github.com/gawkermedia/javascript)
- **GeneralElectric**: [GeneralElectric/javascript](https://github.com/GeneralElectric/javascript)
- **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style)
- **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript)
- **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript)
- **Mighty Spring**: [mightyspring/javascript](https://github.com/mightyspring/javascript)
- **MinnPost**: [MinnPost/javascript](https://github.com/MinnPost/javascript)
- **ModCloth**: [modcloth/javascript](https://github.com/modcloth/javascript)
- **Money Advice Service**: [moneyadviceservice/javascript](https://github.com/moneyadviceservice/javascript)
- **Muber**: [muber/javascript](https://github.com/muber/javascript)
- **National Geographic**: [natgeo/javascript](https://github.com/natgeo/javascript)
- **National Park Service**: [nationalparkservice/javascript](https://github.com/nationalparkservice/javascript)
- **Orion Health**: [orionhealth/javascript](https://github.com/orionhealth/javascript)
- **Peerby**: [Peerby/javascript](https://github.com/Peerby/javascript)
- **Razorfish**: [razorfish/javascript-style-guide](https://github.com/razorfish/javascript-style-guide)
- **reddit**: [reddit/styleguide/javascript](https://github.com/reddit/styleguide/tree/master/javascript)
- **REI**: [reidev/js-style-guide](https://github.com/reidev/js-style-guide)
- **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide)
- **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide)
- **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript)
- **TheLadders**: [TheLadders/javascript](https://github.com/TheLadders/javascript)  
- **Userify**: [userify/javascript](https://github.com/userify/javascript)
- **Zillow**: [zillow/javascript](https://github.com/zillow/javascript)
- **ZocDoc**: [ZocDoc/javascript](https://github.com/ZocDoc/javascript)

## Translation

This style guide is also available in other languages:

- :de: **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide)
- :jp: **Japanese**: [mitsuruog/javacript-style-guide](https://github.com/mitsuruog/javacript-style-guide)
- :br: **Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide)
- :cn: **Chinese**: [adamlu/javascript-style-guide](https://github.com/adamlu/javascript-style-guide)
- :es: **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide)
- :kr: **Korean**: [tipjs/javascript-style-guide](https://github.com/tipjs/javascript-style-guide)
- :fr: **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide)
- :ru: **Russian**: [uprock/javascript](https://github.com/uprock/javascript)
- :bg: **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript)

## The JavaScript Style Guide Guide

- [Reference](https://github.com/airbnb/javascript/wiki/The-JavaScript-Style-Guide-Guide)

## Contributors

- [View Contributors](https://github.com/airbnb/javascript/graphs/contributors)


## License

(The MIT License)

Copyright (c) 2014 Airbnb

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

**[⬆ back to top](#table-of-contents)**

# };

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%