有什么原因Crockford recommends使用 else statement
和花括号在同一条线上?
if (condition) {
statements
} else {
statements
}
最佳答案
它看起来比:
if(condition){
statements
}
else {
statements
}
加上它与
if
相关联和 else
逻辑上组合在一起,这样更容易阅读。
关于JavaScript 代码约定 - if 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9674785/