ES6中const对象键的命名约定 [英] Naming convention for const object keys in ES6
问题描述
es6中const对象中的键名是否有推荐的命名约定?我无法找到一个资源,说明它们应该是大写还是小写。
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
};
来自这篇MDN文章的示例显示了这两种风格,所以两者都可以接受。
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.
使用 NAMES_LIKE_THIS
对于常量值。
使用 @const
表示一个常量(不可重写)指针(变量或属性) )。
Use @const
to indicate a constant (non-overwritable) pointer (a variable or property).
谷歌javascript指南
https://google.github.io/styleguide/javascriptguide.xml
这篇关于ES6中const对象键的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!