CodesJava

Easy learning with example program codes

javascript comment tutorial


JavaScript comments are used to explain the JavaScript code logic. JavaScript comments are ignored by JavaScript translator. It makes JavaScript code more readable.

Types of JavaScript comments:

1. Single-line Comment
2. Multi-line Comment

JavaScript Single-line Comment:

The double forward slashes (//) are used for Single line comments. Anything between // to end of the line will be ignored by JavaScript translator.

Syntax:

<script>  
//Single line comment  
JavaScript Code
</script>

JavaScript Single-line Comment Example:

<html>
<body>
<script>  
// Single line comment  
document.write("Hello codesjava.com");  
</script> 
</body>
</html>

Output:

JS Bin on jsbin.com

JavaScript Multi-line Comment:

The Multi line comments start with forward slash with asterisk /* and end with asterisk with forward slash*/. Anything between /* and */ will be ignored by JavaScript translator. It can be used to comment single as well as multiple lines.

Syntax:

<script>  
/* Multi-line comment  
This line will not execute */
JavaScript Code
</script>

JavaScript Multi-line Comment Example:

<html>
<body>
<script>  
/* Multi-line comment  
This line will not execute */
document.write("Hello codesjava.com");  
</script> 
</body> 
</html>

Output:

JS Bin on jsbin.com
 



Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki