首页 新闻 搜索 专区 学院

在google Js代码中看到了将常量

0
[已解决问题] 解决于 2014-07-16 17:17
/**
 * Request timeout in milliseconds.
 * @type {number}
 */
goog.example.TIMEOUT_IN_MILLISECONDS = 60;

着实没明白什么意思

@tyoe {number} 标记之后,编译器就能主动识别常量?



Note that @const does not necessarily imply CONSTANT_VALUES_CASE. However, CONSTANT_VALUES_CASE does imply @const.

/**
 * Request timeout in milliseconds.
 * @type {number}
 */
goog.example.TIMEOUT_IN_MILLISECONDS = 60;

The number of seconds in a minute never changes. It is a constant value. ALL_CAPS also implies @const, so the constant cannot be overwritten.

The open source compiler will allow the symbol it to be overwritten because the constant is not marked as @const.

/**
 * Map of URL to response string.
 * @const
 */
MyClass.fetchedUrlCache_ = new goog.structs.Map();

In this case, the pointer can never be overwritten, but value is highly mutable and not constant (and thus in camelCase, not ALL_CAPS).

CallMeTommy的主页 CallMeTommy | 初学一级 | 园豆:70
提问于:2013-01-16 15:16
< >
分享
最佳答案
0

这不是一段注释吗?

 

另外,JS有常量?

奖励园豆:5
十年灯 | 菜鸟二级 |园豆:356 | 2013-02-20 11:14
其他回答(1)
0

类似JAVA DOC

用来生成文档的注释,{}里面写的是类型,JS里面的类型有string、number、boolean等等

搜索下你就知道是什么了

Arliang | 园豆:360 (菜鸟二级) | 2013-06-02 22:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册