mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-13 21:48:05 -05:00
Update README.md
This commit is contained in:
36
README.md
36
README.md
@@ -41,7 +41,7 @@
|
||||
|
||||
## Types
|
||||
|
||||
- **Primitives**: When you access a primitive type you work directly on its value
|
||||
- **Primitives**: When you access a primitive type you work directly on its value.
|
||||
|
||||
+ `string`
|
||||
+ `number`
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
console.log(foo, bar); // => 1, 9
|
||||
```
|
||||
- **Complex**: When you access a complex type you work on a reference to its value
|
||||
- **Complex**: When you access a complex type you work on a reference to its value.
|
||||
|
||||
+ `object`
|
||||
+ `array`
|
||||
@@ -86,7 +86,7 @@
|
||||
var item = {};
|
||||
```
|
||||
|
||||
- Don't use [reserved words](http://es5.github.io/#x7.6.1) as keys. It won't work in IE8. [More info](https://github.com/airbnb/javascript/issues/61)
|
||||
- Don't use [reserved words](http://es5.github.io/#x7.6.1) as keys. It won't work in IE8. [More info](https://github.com/airbnb/javascript/issues/61).
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -125,7 +125,7 @@
|
||||
|
||||
## Arrays
|
||||
|
||||
- Use the literal syntax for array creation
|
||||
- Use the literal syntax for array creation.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -178,7 +178,7 @@
|
||||
|
||||
## Strings
|
||||
|
||||
- Use single quotes `''` for strings
|
||||
- Use single quotes `''` for strings.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -195,7 +195,7 @@
|
||||
```
|
||||
|
||||
- Strings longer than 80 characters should be written across multiple lines using string concatenation.
|
||||
- Note: If overused, long strings with concatenation could impact performance. [jsPerf](http://jsperf.com/ya-string-concat) & [Discussion](https://github.com/airbnb/javascript/issues/40)
|
||||
- Note: If overused, long strings with concatenation could impact performance. [jsPerf](http://jsperf.com/ya-string-concat) & [Discussion](https://github.com/airbnb/javascript/issues/40).
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -557,7 +557,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/)
|
||||
- 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/).
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
@@ -606,7 +606,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
|
||||
- For more information see [Truth Equality and JavaScript](http://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll.
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
@@ -706,7 +706,7 @@
|
||||
|
||||
- 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
|
||||
- Use `// FIXME:` to annotate problems.
|
||||
|
||||
```javascript
|
||||
function Calculator() {
|
||||
@@ -718,7 +718,7 @@
|
||||
}
|
||||
```
|
||||
|
||||
- Use `// TODO:` to annotate solutions to problems
|
||||
- Use `// TODO:` to annotate solutions to problems.
|
||||
|
||||
```javascript
|
||||
function Calculator() {
|
||||
@@ -735,7 +735,7 @@
|
||||
|
||||
## Whitespace
|
||||
|
||||
- Use soft tabs set to 2 spaces
|
||||
- Use soft tabs set to 2 spaces.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1042,7 +1042,7 @@
|
||||
}
|
||||
```
|
||||
|
||||
- Use camelCase when naming objects, functions, and instances
|
||||
- Use camelCase when naming objects, functions, and instances.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1061,7 +1061,7 @@
|
||||
});
|
||||
```
|
||||
|
||||
- Use PascalCase when naming constructors or classes
|
||||
- Use PascalCase when naming constructors or classes.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1083,7 +1083,7 @@
|
||||
});
|
||||
```
|
||||
|
||||
- Use a leading underscore `_` when naming private properties
|
||||
- Use a leading underscore `_` when naming private properties.
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1143,8 +1143,8 @@
|
||||
|
||||
## Accessors
|
||||
|
||||
- Accessor functions for properties are not required
|
||||
- If you do make accessor functions use getVal() and setVal('hello')
|
||||
- Accessor functions for properties are not required.
|
||||
- If you do make accessor functions use getVal() and setVal('hello').
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1160,7 +1160,7 @@
|
||||
dragon.setAge(25);
|
||||
```
|
||||
|
||||
- If the property is a boolean, use isVal() or hasVal()
|
||||
- If the property is a boolean, use isVal() or hasVal().
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1406,7 +1406,7 @@
|
||||
|
||||
## ECMAScript 5 Compatibility
|
||||
|
||||
- Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/)
|
||||
- Refer to [Kangax](https://twitter.com/kangax/)'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/).
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user