我应该在JavaScript中使用分号吗? [英] Should I use semicolons in JavaScript?

查看:129
本文介绍了我应该在JavaScript中使用分号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只编写了少量运行嵌入Java应用程序的JavaScript,但是使用 QUnit进行了测试,混合了,我还没有发现任何问题。

I've only written a small amount of JavaScript that runs embedded in a Java application, but it was tested using QUnit, has been mixed, and I've not noticed any problems yet.

是否有一些传统的智慧是否在JavaScript中使用分号?

Is there some conventional wisdom whether to use semicolons or not in JavaScript?

推荐答案

使用它们。经常使用它们。

因为你忽略了一个分号并且它丢失了以前保存它的空格,所以稍后容易打破一些东西太容易了。压缩/生成/评估解析。

It's far too easy to have something break later on because you neglected a semi-colon and it lost the whitespace which saved it before in a compression/generation/eval parse.

这篇关于我应该在JavaScript中使用分号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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