Skip to content

Commit 6220506

Browse files
committed
Don't use reserved words as property names. If you do, quote them. fixes airbnb#6
1 parent 437e33a commit 6220506

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,26 @@
8080
var item = {};
8181
```
8282

83-
- Avoid using reserved words as property names. If you do use them, wrap them in single quotes.
83+
- Don't use [reserved words](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words) as property names. If you do use them, wrap them in single quotes.
8484
8585
```javascript
8686
// bad
8787
var superman = {
88-
class: 'superhero'
88+
class: 'superhero',
89+
default: { clark: kent },
90+
private: true
8991
};
9092
9193
// good
9294
var superman = {
93-
klass: 'superhero'
95+
klass: 'superhero',
96+
defaults: { clark: kent },
97+
hidden: true
9498
};
9599
96100
// good
97101
var superman = {
98-
'class': 'superhero'
102+
'class': 'superhero',
99103
};
100104
```
101105
**[[⬆]](#TOC)**

0 commit comments

Comments
 (0)