Naming convention for const object keys in ES6

前端 未结 4 1053
情话喂你
情话喂你 2021-01-31 08:03

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 lowercas

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 08:44

    Google once recommended the following:

    const COLOR_CODES = {
      BLUE: 1,
      RED: 1
    };
    

    See: https://google.github.io/styleguide/javascriptguide.xml#Constants

    • Use NAMES_LIKE_THIS for constant values.
    • Use @const to indicate a constant (non-overwritable) pointer (a variable or property).
    • Never use the const keyword as it's not supported in Internet Explorer.

    However, the updated style guidelines have different recommendations.

提交回复
热议问题