Javascript annotations can be used to enhance code readability.
Javascript comments
You can add comments to explain JavaScript or improve its readability.
What is a single row between two rows? // Start.
This example uses a single line comment to explain the Code:
<SCRIPT type = "text/JavaScript"> // output title of this line of code: document. write ("
Tiy
Javascript multi-line comment
Multi-line comments start with/* and end.
This example uses multi-line annotations to explain the Code:
<SCRIPT type = "text/JavaScript">/* the following code outputs a title and two paragraphs */document. write ("
Tiy
Use annotations to prevent execution
In this example, we use annotations to prevent the execution of a line of code:
<script type="text/javascript">document.write("
Tiy
In this example, we use annotations to prevent execution of several lines of code:
<script type="text/javascript">/*document.write("
Tiy
Comment at the end of the row
In this example, the comment is placed at the end of the statement line:
<SCRIPT type = "text/JavaScript"> document. write ("hello"); // output "hello" document. write ("world"); // output "world" </SCRIPT>