Whe*_*lie 22 javascript coding-style
我们正在考虑在公司内部采用Google JavaScript编码指南来保持项目之间的一致性,但有一点令我感到困惑.在关于常量的部分中,它说使用@const关键字注释进行编译时常量强制执行,但我之前从未遇到过@符号.这是Google扩展程序还是核心语言的一部分?
这是全文:
对于非基元,请使用
@const注释.
/**
* The number of seconds in each of the given units.
* @type {Object.<number>}
* @const
*/
goog.example.SECONDS_TABLE = {
minute: 60,
hour: 60 * 60
day: 60 * 60 * 24
}
Run Code Online (Sandbox Code Playgroud)
这允许编译器强制执行常量.
至于
const关键字,Internet Explorer不解析它,所以不要使用它.