Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the double slash mean in 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?

like image 655
Andrea Verde Avatar asked Feb 12 '26 15:02

Andrea Verde


1 Answers

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>

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

like image 126
Nathan Avatar answered Feb 15 '26 04:02

Nathan