Allman风格在JavaScript中的危险含义 [英] Dangerous implications of Allman style in JavaScript

查看:222
本文介绍了Allman风格在JavaScript中的危险含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不记得在哪里,但最近我通过了评论,用户告诉我1TBS比JavaScript中的Allman更受欢迎,并说Allman在JavaScript中有危险的含义。

I cannot remember where, but recently I passed a comment where the user told that 1TBS is more preferred than Allman in JavaScript and said Allman has dangerous implications in JavaScript.

这是一个有效的声明吗?如果是这样,为什么?

Was it a valid statement? If so, why?

推荐答案

返回不能 LineTerminator 之后:

return
{


};

被视为返回; (返回 undefined )而不是 return {}; (返回一个对象)

is treated as return; (return undefined) instead of return {}; (return an object)

请参阅 自动分号插入(ASI)的规则 更多信息。

See the rules for Automatic Semicolon Insertion (ASI) for more.

这篇关于Allman风格在JavaScript中的危险含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆