我是否应该为 JavaScript 代码写州名、首府城市的名称,而它的命名约定建议采用驼峰式大小写

Should I write the name of states, cities in capitals for JavaScript code while it's naming conventions suggest camel case

我是一名初级 JS 开发人员,我不确定 best practice 对可能连接到前端接口的变量的命名考虑了什么。 例如,我正在尝试提供 list of the states and their cities;我想知道我是否应该遵守 JS naming conventions 编写对象 属性 名称或将它们写在 CAPITALS. 中 而且,我应该在多部分名称之间放置 space 还是更好?

总结:

例如:

let states = {
    Alabama: ["Alexander City", "Andalusia", "Anniston", "Athens"],
    Alaska: ["Anchorage", "Cordova"],
    Arizona: ["Lake Havasu City", "Window Rock"],
    Arkansas: ["Arkadelphia", "Benton"],
    California: ["Costa Mesa", "Mountain View"],
};

camelCasing 通常用作命名变量和有时是对象键的最佳实践;但是,对象键可以是 snake_cased 或者 首字母大写 并且仍然遵循最佳实践。

数组值很好,应该保持原样。