File tree 1 file changed +20
-3
lines changed 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 83
83
var item = {};
84
84
` ` `
85
85
86
- - Don' t use [reserved words](https ://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words ) as keys.
86
+ - 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)
87
87
88
88
` ` ` javascript
89
89
// bad
90
90
var superman = {
91
- class: ' superhero' ,
92
91
default: { clark: 'kent' },
93
92
private: true
94
93
};
95
94
96
95
// good
97
96
var superman = {
98
- klass: ' superhero' ,
99
97
defaults: { clark: 'kent' },
100
98
hidden: true
101
99
};
102
100
` ` `
101
+
102
+ - Use readable synonyms in place of reserved words.
103
+
104
+ ` ` ` javascript
105
+ // bad
106
+ var superman = {
107
+ class: 'alien'
108
+ };
109
+
110
+ // bad
111
+ var superman = {
112
+ klass: 'alien'
113
+ };
114
+
115
+ // good
116
+ var superman = {
117
+ type: 'alien'
118
+ };
119
+ ` ` `
103
120
** [[⬆]](#TOC )**
104
121
105
122
## < a name= ' arrays' > Arrays< / a>
You can’t perform that action at this time.
0 commit comments