JavaScript中的双斜线意味着什么? [英] What does the double slash mean in JavaScript?

查看:142
本文介绍了JavaScript中的双斜线意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在脚本中找到了这个部分

I've found this piece in a script

var name = project.SMALL_WIDTH//p.containerWidth() /// 2//project.WIDTH / 4

双斜杠和三斜杠是什么意思?

What do the double and the triple slash mean?

推荐答案

/// (最有可能)只有划分评论的部分内容。但是,它们对代码没有任何影响。浏览器不会呈现JavaScript代码中 // 之后的所有内容。你可以这样做,它仍然可以工作:

The /// is (most likely) there only to divide up parts of the comment. But, they don't have any affect in the code. Everything after a // in a JavaScript code is not rendered by the browser. You could do this and it would still work:

<script type="text/javascript">
// Hello! I'm a comment! ///////////////// these slashes don't do anything as they're in a comment.
// The double slashes tell the browser not to render it.
</script>

此外,您还可以进行多行评论:

Also, you can do multiple line comments:

<script type="text/javascript">
/*
This is a 
multiple 
line 
comment!
*/
</script>

如您所见,JavaScript中的多行注释与CSS注释非常相似。

As you can see, multiple line comments in JavaScript are very similar to CSS comments.

这篇关于JavaScript中的双斜线意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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