Rely on github's default heading anchors

This commit is contained in:
Koen Punt
2014-03-16 15:24:43 +01:00
parent 8bf39432c6
commit c3a9c7f741

View File

@@ -3,7 +3,7 @@
*A mostly reasonable approach to JavaScript*
## <a name='TOC'>Table of Contents</a>
## Table of Contents
1. [Types](#types)
1. [Objects](#objects)
@@ -13,30 +13,30 @@
1. [Properties](#properties)
1. [Variables](#variables)
1. [Hoisting](#hoisting)
1. [Conditional Expressions & Equality](#conditionals)
1. [Conditional Expressions & Equality](#conditional-expressions--equality)
1. [Blocks](#blocks)
1. [Comments](#comments)
1. [Whitespace](#whitespace)
1. [Commas](#commas)
1. [Semicolons](#semicolons)
1. [Type Casting & Coercion](#type-coercion)
1. [Type Casting & Coercion](#type-casting--coercion)
1. [Naming Conventions](#naming-conventions)
1. [Accessors](#accessors)
1. [Constructors](#constructors)
1. [Events](#events)
1. [Modules](#modules)
1. [jQuery](#jquery)
1. [ES5 Compatibility](#es5)
1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility)
1. [Testing](#testing)
1. [Performance](#performance)
1. [Resources](#resources)
1. [In the Wild](#in-the-wild)
1. [Translation](#translation)
1. [The JavaScript Style Guide Guide](#guide-guide)
1. [The JavaScript Style Guide Guide](#the-javascript-style-guide-guide)
1. [Contributors](#contributors)
1. [License](#license)
## <a name='types'>Types</a>
## Types
- **Primitives**: When you access a primitive type you work directly on its value
@@ -71,7 +71,7 @@
**[[⬆]](#TOC)**
## <a name='objects'>Objects</a>
## Objects
- Use the literal syntax for object creation.
@@ -119,7 +119,7 @@
```
**[[⬆]](#TOC)**
## <a name='arrays'>Arrays</a>
## Arrays
- Use the literal syntax for array creation
@@ -172,7 +172,7 @@
**[[⬆]](#TOC)**
## <a name='strings'>Strings</a>
## Strings
- Use single quotes `''` for strings
@@ -262,7 +262,7 @@
**[[⬆]](#TOC)**
## <a name='functions'>Functions</a>
## Functions
- Function expressions:
@@ -321,7 +321,7 @@
## <a name='properties'>Properties</a>
## Properties
- Use dot notation when accessing properties.
@@ -356,7 +356,7 @@
**[[⬆]](#TOC)**
## <a name='variables'>Variables</a>
## 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.
@@ -465,7 +465,7 @@
**[[⬆]](#TOC)**
## <a name='hoisting'>Hoisting</a>
## Hoisting
- Variable declarations get hoisted to the top of their scope, their assignment does not.
@@ -555,7 +555,7 @@
## <a name='conditionals'>Conditional Expressions & Equality</a>
## Conditional Expressions & Equality
- Use `===` and `!==` over `==` and `!=`.
- Conditional expressions are evaluated using coercion with the `ToBoolean` method and always follow these simple rules:
@@ -603,7 +603,7 @@
**[[⬆]](#TOC)**
## <a name='blocks'>Blocks</a>
## Blocks
- Use braces with all multi-line blocks.
@@ -632,7 +632,7 @@
**[[⬆]](#TOC)**
## <a name='comments'>Comments</a>
## Comments
- Use `/** ... */` for multiline comments. Include a description, specify types and values for all parameters and return values.
@@ -725,7 +725,7 @@
**[[⬆]](#TOC)**
## <a name='whitespace'>Whitespace</a>
## Whitespace
- Use soft tabs set to 2 spaces
@@ -832,7 +832,7 @@
**[[⬆]](#TOC)**
## <a name='commas'>Commas</a>
## Commas
- Leading commas: **Nope.**
@@ -895,7 +895,7 @@
**[[⬆]](#TOC)**
## <a name='semicolons'>Semicolons</a>
## Semicolons
- **Yup.**
@@ -922,7 +922,7 @@
**[[⬆]](#TOC)**
## <a name='type-coercion'>Type Casting & Coercion</a>
## Type Casting & Coercion
- Perform type coercion at the beginning of the statement.
- Strings:
@@ -998,7 +998,7 @@
**[[⬆]](#TOC)**
## <a name='naming-conventions'>Naming Conventions</a>
## Naming Conventions
- Avoid single letter names. Be descriptive with your naming.
@@ -1111,7 +1111,7 @@
**[[⬆]](#TOC)**
## <a name='accessors'>Accessors</a>
## Accessors
- Accessor functions for properties are not required
- If you do make accessor functions use getVal() and setVal('hello')
@@ -1165,7 +1165,7 @@
**[[⬆]](#TOC)**
## <a name='constructors'>Constructors</a>
## Constructors
- Assign methods to the prototype object, instead of overwriting the prototype with a new object. Overwriting the prototype makes inheritance impossible: by resetting the prototype you'll overwrite the base!
@@ -1250,7 +1250,7 @@
**[[⬆]](#TOC)**
## <a name='events'>Events</a>
## 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:
@@ -1281,7 +1281,7 @@
**[[⬆]](#TOC)**
## <a name='modules'>Modules</a>
## 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.
@@ -1312,7 +1312,7 @@
**[[⬆]](#TOC)**
## <a name='jquery'>jQuery</a>
## jQuery
- Prefix jQuery object variables with a `$`.
@@ -1374,14 +1374,14 @@
**[[⬆]](#TOC)**
## <a name='es5'>ECMAScript 5 Compatibility</a>
## ECMAScript 5 Compatibility
- Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/)
**[[⬆]](#TOC)**
## <a name='testing'>Testing</a>
## Testing
- **Yup.**
@@ -1394,7 +1394,7 @@
**[[⬆]](#TOC)**
## <a name='performance'>Performance</a>
## Performance
- [On Layout & Web Performance](http://kellegous.com/j/2013/01/26/layout-performance/)
- [String vs Array Concat](http://jsperf.com/string-vs-array-concat/2)
@@ -1408,7 +1408,7 @@
**[[⬆]](#TOC)**
## <a name='resources'>Resources</a>
## Resources
**Read This**
@@ -1466,7 +1466,7 @@
**[[⬆]](#TOC)**
## <a name='in-the-wild'>In the Wild</a>
## 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.
@@ -1495,7 +1495,7 @@
- **Zillow**: [zillow/javascript](https://github.com/zillow/javascript)
- **ZocDoc**: [ZocDoc/javascript](https://github.com/ZocDoc/javascript)
## <a name='translation'>Translation</a>
## Translation
This style guide is also available in other languages:
@@ -1509,16 +1509,16 @@
- :ru: **Russian**: [uprock/javascript](https://github.com/uprock/javascript)
- :bg: **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript)
## <a name='guide-guide'>The JavaScript Style Guide Guide</a>
## The JavaScript Style Guide Guide
- [Reference](https://github.com/airbnb/javascript/wiki/The-JavaScript-Style-Guide-Guide)
## <a name='authors'>Contributors</a>
## Contributors
- [View Contributors](https://github.com/airbnb/javascript/graphs/contributors)
## <a name='license'>License</a>
## License
(The MIT License)