-
Notifications
You must be signed in to change notification settings - Fork 67
Javascript Conventions
Sam Matthews edited this page May 22, 2015
·
4 revisions
#Javascript Conventions
var ourStyleGuide = {
/*
**
** This comment relates to a block of code. It's usually written
** above a function.
**
*/
fooBar: function ( pow, whamo ) { // Spaces between 'function' and parenthesis, spaces between args and parenthesis
// A double slashed comment above a line explains following line's purpose
console.log("Doing something"); // Double slashed comment after command clarifies functionality
// TODO: Comments like these are used to comment on needs for refactor or raise questions
}
}
// when working with objects
for ( var x in y ) { ... }
// when working with arrays
for ( var x; x < y.length; x++ ) { ... }