Is there a recommended naming convention for key names within a const object in ES6? I haven't been able to find a resource which states if they should be uppercase or lowercase.
const COLOR_CODES = {
BLUE: 1,
RED: 1
};
vs
const COLOR_CODES = {
blue: 1,
red: 1
};
The examples from this MDN article show both styles, so maybe both are acceptable.
According to Google it would be all caps. Speaking from experience, most of the other programming languages have all caps so I would suggest using that.
Use NAMES_LIKE_THIS
for constant values.
Use @const
to indicate a constant (non-overwritable) pointer (a variable or property).
Google javascript guide https://google.github.io/styleguide/javascriptguide.xml