Skip to content

Commit

Permalink
[objects] update discussion on reserved word usage. fixes #61
Browse files Browse the repository at this point in the history
  • Loading branch information
hshoff committed Aug 7, 2013
1 parent ae425f0 commit 020fe03
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,40 @@
var item = {};
```

- Don't use [reserved words](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words) as keys.
- 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
var superman = {
class: 'superhero',
default: { clark: 'kent' },
private: true
};
// good
var superman = {
klass: 'superhero',
defaults: { clark: 'kent' },
hidden: true
};
```

- Use readable synonyms in place of reserved words.

```javascript
// bad
var superman = {
class: 'alien'
};
// bad
var superman = {
klass: 'alien'
};
// good
var superman = {
type: 'alien'
};
```
**[[⬆]](#TOC)**

## <a name='arrays'>Arrays</a>
Expand Down

0 comments on commit 020fe03

Please sign in to comment.