|
| 1 | +[原文章: https://github.com/airbnb/javascript](https://github.com/airbnb/javascript) |
| 2 | + |
| 3 | +注:本人根据自己的开发习惯删除和修改了部分规范 |
| 4 | + |
1 | 5 | # JavaScript规范 |
2 | 6 |
|
3 | 7 | ## <a name='TOC'>内容列表</a> |
|
887 | 891 | }); |
888 | 892 | ``` |
889 | 893 |
|
890 | | - - 命名私有属性时前面加个下划线 `_` |
| 894 | + - 命名私有属性时前面加个下划线 `_` |
891 | 895 |
|
892 | 896 | ```javascript |
893 | 897 | // bad |
|
1104 | 1108 | - 开始,这保证了如果一个有问题的模块忘记包含最后的分号在合并后不会出现错误 |
1105 | 1109 | - 这个文件应该以驼峰命名,并在同名文件夹下,同时导出的时候名字一致 |
1106 | 1110 | - 加入一个名为noConflict()的方法来设置导出的模块为之前的版本并返回它 |
1107 | | - - 总是在模块顶部声明 `'use strict';` |
| 1111 | + - 总是在模块顶部声明 `'use strict';` |
1108 | 1112 |
|
1109 | 1113 | ```javascript |
1110 | 1114 | // fancyInput/fancyInput.js |
|
1170 | 1174 | ``` |
1171 | 1175 |
|
1172 | 1176 | - 对DOM查询使用级联的 `$('.sidebar ul')` 或 `$('.sidebar ul')`,[jsPerf](http://jsperf.com/jquery-find-vs-context-sel/16) |
1173 | | - - 对有作用域的jQuery对象查询使用 `find` |
| 1177 | + - 对有作用域的jQuery对象查询使用 `find` |
1174 | 1178 |
|
1175 | 1179 | ```javascript |
1176 | 1180 | // bad |
|
1219 | 1223 |
|
1220 | 1224 | ## <a name='resources'>资源</a> |
1221 | 1225 |
|
1222 | | -
|
1223 | 1226 | **Read This** |
1224 | 1227 |
|
1225 | 1228 | - [Annotated ECMAScript 5.1](http://es5.github.com/) |
1226 | 1229 |
|
1227 | | -**Other Styleguides** |
| 1230 | +**其它规范** |
1228 | 1231 |
|
1229 | 1232 | - [Google JavaScript Style Guide](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml) |
1230 | 1233 | - [jQuery Core Style Guidelines](http://docs.jquery.com/JQuery_Core_Style_Guidelines) |
1231 | 1234 | - [Principles of Writing Consistent, Idiomatic JavaScript](https://github.com/rwldrn/idiomatic.js/) |
1232 | 1235 |
|
1233 | | -**Other Styles** |
| 1236 | +**其它风格** |
1234 | 1237 |
|
1235 | 1238 | - [Naming this in nested functions](https://gist.github.com/4135065) - Christian Johansen |
1236 | 1239 | - [Conditional Callbacks](https://github.com/airbnb/javascript/issues/52) |
1237 | 1240 |
|
1238 | | -**Further Reading** |
| 1241 | +**阅读更多** |
1239 | 1242 |
|
1240 | 1243 | - [Understanding JavaScript Closures](http://javascriptweblog.wordpress.com/2010/10/25/understanding-javascript-closures/) - Angus Croll |
1241 | 1244 |
|
1242 | | -**Books** |
| 1245 | +**书籍** |
1243 | 1246 |
|
1244 | 1247 | - [JavaScript: The Good Parts](http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742) - Douglas Crockford |
1245 | 1248 | - [JavaScript Patterns](http://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752) - Stoyan Stefanov |
|
1250 | 1253 | - [Pro JavaScript Techniques](http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273) - John Resig |
1251 | 1254 | - [Smashing Node.js: JavaScript Everywhere](http://www.amazon.com/Smashing-Node-js-JavaScript-Everywhere-Magazine/dp/1119962595) - Guillermo Rauch |
1252 | 1255 |
|
1253 | | -**Blogs** |
| 1256 | +**博客** |
1254 | 1257 |
|
| 1258 | + - [Adam Lu](http://adamlu.com/) |
1255 | 1259 | - [DailyJS](http://dailyjs.com/) |
1256 | 1260 | - [JavaScript Weekly](http://javascriptweekly.com/) |
1257 | 1261 | - [JavaScript, JavaScript...](http://javascriptweblog.wordpress.com/) |
|
1293 | 1297 | - :de: **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide) |
1294 | 1298 | - :jp: **Japanese**: [mitsuruog/javacript-style-guide](https://github.com/mitsuruog/javacript-style-guide) |
1295 | 1299 | - :br: **Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide) |
1296 | | - - :zh: **Chinese**: [adamlu/javascript-style-guide](https://github.com/adamlu/javascript-style-guide) |
| 1300 | + - :cn: **Chinese**: [adamlu/javascript-style-guide](https://github.com/adamlu/javascript-style-guide) |
1297 | 1301 |
|
1298 | | -## <a name='guide-guide'>The JavaScript Style Guide Guide</a> |
| 1302 | +## <a name='guide-guide'>JavaScript风格指南</a> |
1299 | 1303 |
|
1300 | 1304 | - [Reference](https://github.com/airbnb/javascript/wiki/The-JavaScript-Style-Guide-Guide) |
1301 | 1305 |
|
1302 | | -## <a name='authors'>Contributors</a> |
| 1306 | +## <a name='authors'>贡献者</a> |
1303 | 1307 |
|
1304 | 1308 | - [View Contributors](https://github.com/airbnb/javascript/graphs/contributors) |
1305 | 1309 |
|
|
0 commit comments