Skip to content

Commit

Permalink
Merge pull request #5819 from Automattic/update/docs-js-upper-case-co…
Browse files Browse the repository at this point in the history
…nstants

Docs: Include paragraph about SCREAMING_SNAKE_CASE constants (JS)
  • Loading branch information
aduth committed Jun 6, 2016
2 parents 3d977b9 + ca61bb9 commit fb74a4d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/coding-guidelines/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,20 @@ var userIdToDelete, siteUrl;
var userIDToDelete, siteURL;
```

Names should be descriptive, but not excessively so. Exceptions are allowed for iterators, such as the use of `i` to represent the index in a loop.

Constructors intended for use with new should have a capital first letter (UpperCamelCase).

Names should be descriptive, but not excessively so. Exceptions are allowed for iterators, such as the use of `i` to represent the index in a loop.
Variables intended to be used as a [constant](https://en.wikipedia.org/wiki/Constant_(computer_programming)) can be defined with the [SCREAMING_SNAKE_CASE naming convention](https://en.wikipedia.org/wiki/Snake_case). Note that while any variable declared using `const` could be considered a constant, in the context of our application this usage should usually be limited to top-level or exported module values.

```js
const DUMMY_VALUE = 10;

function getIncrementedDummyValue() {
const incrementedValue = DUMMY_VALUE + 1;
return incrementedValue;
}
```

## Comments

Expand Down

0 comments on commit fb74a4d

Please sign in to comment.