Like most of our articles, these conventions serve as our living, breathing coding guidelines for projects we undertake.
The conventions may change from time to time, and represent our best thoughts on the subject.
Javascript
Variables and functions, where it makes sense, should start with a lower case letter.
Both functions and variable names should use snakeCase for naming.
Functions that require initialisation (via new
) should start with a capital letter.
For private variables, we use closure to scope them correctly.
var allTiles = function(){ var _tiles = []; //<-- private variable return { set: function(tiles){ //<-- accessor for that variable _tiles = tiles; }, get: function(){ return _tiles; } } }();
We have safely wrapper the _tiles
variable from the developer and can make adjustments as necessary in the getter/setter.