From c3a9c7f7412ab47b2c5121ec0aa9c09907c95d26 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sun, 16 Mar 2014 15:24:43 +0100 Subject: [PATCH 1/2] Rely on github's default heading anchors --- README.md | 70 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 3f1cd89ed0..4821dd7fce 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ *A mostly reasonable approach to JavaScript* -## Table of Contents +## 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) -## Types +## Types - **Primitives**: When you access a primitive type you work directly on its value @@ -71,7 +71,7 @@ **[[⬆]](#TOC)** -## Objects +## Objects - Use the literal syntax for object creation. @@ -119,7 +119,7 @@ ``` **[[⬆]](#TOC)** -## Arrays +## Arrays - Use the literal syntax for array creation @@ -172,7 +172,7 @@ **[[⬆]](#TOC)** -## Strings +## Strings - Use single quotes `''` for strings @@ -262,7 +262,7 @@ **[[⬆]](#TOC)** -## Functions +## Functions - Function expressions: @@ -321,7 +321,7 @@ -## Properties +## Properties - Use dot notation when accessing properties. @@ -356,7 +356,7 @@ **[[⬆]](#TOC)** -## Variables +## 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)** -## Hoisting +## Hoisting - Variable declarations get hoisted to the top of their scope, their assignment does not. @@ -555,7 +555,7 @@ -## Conditional Expressions & Equality +## 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)** -## Blocks +## Blocks - Use braces with all multi-line blocks. @@ -632,7 +632,7 @@ **[[⬆]](#TOC)** -## Comments +## Comments - Use `/** ... */` for multiline comments. Include a description, specify types and values for all parameters and return values. @@ -725,7 +725,7 @@ **[[⬆]](#TOC)** -## Whitespace +## Whitespace - Use soft tabs set to 2 spaces @@ -832,7 +832,7 @@ **[[⬆]](#TOC)** -## Commas +## Commas - Leading commas: **Nope.** @@ -895,7 +895,7 @@ **[[⬆]](#TOC)** -## Semicolons +## Semicolons - **Yup.** @@ -922,7 +922,7 @@ **[[⬆]](#TOC)** -## Type Casting & Coercion +## Type Casting & Coercion - Perform type coercion at the beginning of the statement. - Strings: @@ -998,7 +998,7 @@ **[[⬆]](#TOC)** -## Naming Conventions +## Naming Conventions - Avoid single letter names. Be descriptive with your naming. @@ -1111,7 +1111,7 @@ **[[⬆]](#TOC)** -## Accessors +## Accessors - Accessor functions for properties are not required - If you do make accessor functions use getVal() and setVal('hello') @@ -1165,7 +1165,7 @@ **[[⬆]](#TOC)** -## Constructors +## 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)** -## Events +## 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)** -## Modules +## 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)** -## jQuery +## jQuery - Prefix jQuery object variables with a `$`. @@ -1374,14 +1374,14 @@ **[[⬆]](#TOC)** -## ECMAScript 5 Compatibility +## ECMAScript 5 Compatibility - Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/) **[[⬆]](#TOC)** -## Testing +## Testing - **Yup.** @@ -1394,7 +1394,7 @@ **[[⬆]](#TOC)** -## Performance +## 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)** -## Resources +## Resources **Read This** @@ -1466,7 +1466,7 @@ **[[⬆]](#TOC)** -## In the Wild +## 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) -## Translation +## 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) -## The JavaScript Style Guide Guide +## The JavaScript Style Guide Guide - [Reference](https://github.com/airbnb/javascript/wiki/The-JavaScript-Style-Guide-Guide) -## Contributors +## Contributors - [View Contributors](https://github.com/airbnb/javascript/graphs/contributors) -## License +## License (The MIT License) From fb86fc032d96597b7b33721a13cc3807d8fb90c0 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sun, 16 Mar 2014 15:38:10 +0100 Subject: [PATCH 2/2] TOC links updated --- README.md | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 4821dd7fce..1bcb08b76f 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ console.log(foo[0], bar[0]); // => 9, 9 ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Objects @@ -117,7 +117,8 @@ type: 'alien' }; ``` - **[[⬆]](#TOC)** + +**[⬆ back to top](#table-of-contents)** ## Arrays @@ -169,7 +170,7 @@ } ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Strings @@ -259,7 +260,7 @@ } ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Functions @@ -317,7 +318,7 @@ } ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** @@ -353,7 +354,7 @@ var isJedi = getProp('jedi'); ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Variables @@ -462,7 +463,7 @@ } ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Hoisting @@ -551,7 +552,7 @@ - For more information refer to [JavaScript Scoping & Hoisting](http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting) by [Ben Cherry](http://www.adequatelygood.com/) - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** @@ -600,7 +601,7 @@ - For more information see [Truth Equality and JavaScript](http://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Blocks @@ -629,7 +630,7 @@ } ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Comments @@ -722,7 +723,7 @@ } ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Whitespace @@ -830,7 +831,7 @@ .call(tron.led); ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Commas @@ -892,7 +893,7 @@ ]; ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Semicolons @@ -919,7 +920,7 @@ })(); ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Type Casting & Coercion @@ -995,7 +996,7 @@ var hasAge = !!age; ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Naming Conventions @@ -1108,7 +1109,7 @@ }; ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Accessors @@ -1162,7 +1163,7 @@ }; ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Constructors @@ -1247,7 +1248,7 @@ }; ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Events @@ -1278,7 +1279,7 @@ }); ``` - **[[⬆]](#TOC)** + **[⬆ back to top](#table-of-contents)** ## Modules @@ -1309,7 +1310,7 @@ }(this); ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## jQuery @@ -1371,14 +1372,14 @@ $sidebar.find('ul').hide(); ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## ECMAScript 5 Compatibility - Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/) - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Testing @@ -1391,7 +1392,7 @@ } ``` - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Performance @@ -1405,7 +1406,7 @@ - [Long String Concatenation](http://jsperf.com/ya-string-concat) - Loading... - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## Resources @@ -1464,7 +1465,7 @@ - [Dustin Diaz](http://dustindiaz.com/) - [nettuts](http://net.tutsplus.com/?s=javascript) - **[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** ## In the Wild @@ -1543,6 +1544,6 @@ 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. -**[[⬆]](#TOC)** +**[⬆ back to top](#table-of-contents)** # };