我是一名初级 JS 开发人员,我不确定best practice
在命名可能连接到前端接口的变量时考虑了什么。例如,我试图提供一个list of the states and their cities
; 我想知道我是否应该遵守 JS naming conventions
for writing Object 属性名称或将它们写在CAPITALS.
而且,我应该在多部分名称之间放置空格还是最好不要?
总结:
例如:
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或首字母大写,并且仍然遵循最佳实践。
数组值很好,应该保持原样。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句