使用google closure compiler我收到以下警告消息:
WARNING - If this if/for/while really shouldnt have a body, use {}.
文档说明如下:
这是否只是一种代码约定,还是由于某种原因
{}
比;
更好? 最佳答案
这样可以防止出现以下情况:
if(condition);
{
// oops, I really meant for this to be conditional.
// now it always executes, regardless of condition.
}
引发的错误迫使您将空的
{}
明确放在;
之前,因此很明显这就是您想要的。