Avoid single-letter names and make names descriptive
Badfunction Q () {//... stuff ...} Goodfunction query () {//... Stuff..}
use camel spelling when naming objects, functions, and instances
Badvar objecttsssss = {};var This_is_my_object = {};function c () {}var u = New User ({name: ' Bob Parr '});//Goodvar this Ismyobject = {};function thisismyfunction () {}var user = new User ({name: ' Bob Parr '});<strong></strong>
when naming constructors or class names, use camel-style notation
Badfunction User (options) {this.name = Options.name;} var bad = new User ({name: ' Nope '});//goodfunction User (options) {this.name = Options.name;} var good = new User ({name: ' yup '});
use a front underline when naming private properties
badthis.__firstname__ = ' Panda '; this.firstname_ = ' Panda ';//goodthis._firstname = ' Panda ';
Use _this when saving this reference
Badfunction () {var = this;return function () {Console.log (self)};} Badfunction () {var = this;return function () {console.log (that);};} Goodfunction () {var _this = This;return function () {console.log (_this);};}
when naming a function, the following method facilitates the stack trace
Badvar log = function (msg) {Console.log (msg);};/ /goodvar log = function log (msg) {Console.log (msg);};
If the file is exported as a class, the filename should be consistent with the class name
File Contentsclass CheckBox {//...} Module.exports = checkbox;//in some other file//badvar checkbox = require ('./checkbox ');//Badvar checkbox = require ('./ Check_box ');//Goodvar CheckBox = require ('./checkbox ');
1:15 and let them is for lights in the firmament of the heaven to give light upon the earth:and it is so.
"Notes" JavaScript coding specification-naming conventions