Tuesday 8 November 2016

Java Script Statements and Comments

Like other programming languages ,in Java Script a code consists of number of statements and a statement may be defined as the instruction or a command given to a system to do something ,this is how the programming language works .We give the system a set of instructions or statements which in turn performs the required task.
Comments may be defined as the use of small understandable notes in the code.It is a good practice to keep lot of comments in your programs as it improves the readability of the code and also it becomes easy for other programmers to understand the code easily. It is also possible to imitate some of the statements by the use of comments.

In Java Script there are two kinds of comments:
Single line Comments and
Multi line Comments
Single line Comments are used in single line and  acts as small notes in code while on the other hand multi line comments can imitate the effect of a complete block of code in a program that is the instructions written under the //......// will not be executed at all.

A single line Comment begins with:

<!-- ...............CODE ..............-->

while multi line Comment begins with
//  ...............CODE ............... //

The following program shows the use of single line comment and multi line comment in a program

<html>
<head>
<title>JavaScript</title>
<script type ="text/javascript">
<!--Prints message -->
document.write(''welcome to JavaScript");

</head>
</html>

No comments:

Post a Comment