Skip to content

Commit f19e34d

Browse files
Add in doc TOC
1 parent 26d396e commit f19e34d

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

manual/en-US/coding-standards/chapters/javascript.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
## JavaScript
22

3+
### Contents
4+
5+
1. [Naming Conventions](#naming-conventions)
6+
- [Variables](#naming-conventions-variables)
7+
- [Functions](#naming-conventions-functions)
8+
- [Reserved Words](#naming-conventions-reserved)
9+
2. [Syntax Style](#syntax-style)
10+
- [Indentation](#syntax-indentation)
11+
- [Spacing](#syntax-spacing)
12+
- [Commas](#syntax-commas)
13+
- [Semicolons](#syntax-semicolons)
14+
- [Quotes](#syntax-quotes)
15+
3. [Types](#types)
16+
4. [Functions](#functions)
17+
5. [Conditional Statements](#conditional-statements)
18+
6. [Blocks & Multi-line Statements](#blocks)
19+
7. [Comments](#comments)
20+
21+
<a name="naming-conventions"></a>
322
## Naming Conventions
423

524
Use descriptive words or terse phrases for names.
625

726
Variables and Functions should be camel case, starting with a lowercase letter: `likeThis`
827

28+
<a name="naming-conventions-variables"></a>
929
### Variables
1030

1131
**Use names that describe what the variable is:**
@@ -16,6 +36,7 @@ Variables and Functions should be camel case, starting with a lowercase letter:
1636

1737
Use i for index in a loop (and subsequent letters when necessary for nested iteration).
1838

39+
<a name="naming-conventions-functions"></a>
1940
### Functions
2041

2142
**Use names that describe what the function does:**
@@ -25,20 +46,22 @@ function getSomeData() {
2546
// statements
2647
}
2748
```
28-
49+
<a name="naming-conventions-reserved"></a>
2950
### Reserved Words
3051

3152
Do not use reserved words for anything other than their intended use. The list of: [Reserved Words](http://es5.github.io/#x7.6.1)
3253

3354
---
3455

56+
<a name="syntax-style"></a>
3557
## Syntax Style
3658

59+
<a name="syntax-indentation"></a>
3760
### Indentation
3861
- Don't mix tabs and spaces.
3962
- Tabs, 4 spaces
4063

41-
64+
<a name="syntax-spacing"></a>
4265
### Spacing
4366
- No whitespace at the end of line or on blank lines.
4467
- Unary special-character operators (e.g., !, ++) must not have space next to their operand.
@@ -119,7 +142,7 @@ foo( data, function() {
119142
});
120143
```
121144

122-
145+
<a name="syntax-commas"></a>
123146
### Commas
124147

125148
**Place commas after:**
@@ -143,7 +166,7 @@ array = [ 'foo', 'bar', ];
143166
array = [ 'foo', 'bar' ];
144167
```
145168

146-
169+
<a name="syntax-semicolons"></a>
147170
### Semicolons
148171

149172
Use them where expected.
@@ -166,14 +189,15 @@ function foo() {
166189
}
167190
```
168191

192+
<a name="syntax-quotes"></a>
169193
### Quotes
170194

171195
Use ' instead of "
172196

173197

174198
---
175199

176-
200+
<a name="variables"></a>
177201
## Variables
178202

179203
### Avoid Global Variables
@@ -218,6 +242,7 @@ var foo = 'bar',
218242
baz = 'qux';
219243
```
220244

245+
<a name="types"></a>
221246
## Types
222247

223248
### String
@@ -317,6 +342,7 @@ var myArr = [];
317342
myArr.push('foo');
318343
```
319344

345+
<a name="functions"></a>
320346
## Functions
321347

322348
### Chaining Method Calls
@@ -328,6 +354,7 @@ $('.someElement')
328354
.fadeIn();
329355
```
330356

357+
<a name="conditional-statements"></a>
331358
## Conditional Statements
332359

333360
Use ternary syntax if:
@@ -387,7 +414,7 @@ Use strict equality operator === so that type is considered in comparison. Using
387414
1 === "1"
388415
```
389416

390-
417+
<a name="blocks"></a>
391418
## Blocks & Multi-line Statements
392419

393420
Use curly braces on blocks that have more than one statement.
@@ -407,7 +434,7 @@ if ( test ) {
407434
}
408435
```
409436

410-
437+
<a name="comments"></a>
411438
## Comments
412439

413440
**Single Line**

0 commit comments

Comments
 (0)