JavaScript Statements And Comments
Javascript code
Javascript Block
Javascript Multiple Comments
Using Comments to Prevent Execution
Using Comments at te end of a Line
Javascript is a case-sensitive
Javascript statements
A JavaScriopt statement is a command to a browser. The purpose of command is to tell the browser what to do.
The semicolon is optional (according to the Javascript standard),
Using Semicolons makes it possible to write multiple statements on one line,
although good programming practice ecourages placing only one statement per line.
Javascript Code
Javascript code(or just javascript ) is a sequence of javascript statements.
Each statement is executed by the browser in the sequenced it is written
<html>
<head>
<script type="text/javascript">
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
Javascript Blocks
The purpose of a block is to make the sequence of statements executed together.
<html>
<body>
<script type="text/javascript">
{
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
}
</script>
</body>
</html>
JavaScript Comments
Javascripts comments can be added to explaine the Javascript script or to make the code more readable.
single line comments starts with //
<html>
<body>
<script type="text/javascript">
//write a heading
document.write("<h1>This is a heading</h1>");
//write two paragraphs:
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
Javascript Multiple Comments
Multiple Comments Starts with /* and end with */
<html>
<body>
<script type="text/javascript">
/* The code below will write
one heading and two paragraphs
*/
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
Using Comments to Prevent Execution
The comments is used to prevent the execution of a single code line.
<html>
<body>
<script type="text/javascript">
//document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
The comment is used to prevent the execution of a code block
<html>
<body>
<script type="text/javascript">
/*
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
*/
</script>
</body>
</html>
Using Comments at the End of a Line
<html>
<head>
<script type="text/javascript">
document.write("hello"); //write "Hello"
document.write("Dolly");//write "Dolly"
</script>
</body>
</html>
Javascript code
Javascript Block
Javascript Multiple Comments
Using Comments to Prevent Execution
Using Comments at te end of a Line
Javascript is a case-sensitive
Javascript statements
A JavaScriopt statement is a command to a browser. The purpose of command is to tell the browser what to do.
The semicolon is optional (according to the Javascript standard),
Using Semicolons makes it possible to write multiple statements on one line,
although good programming practice ecourages placing only one statement per line.
Javascript Code
Javascript code(or just javascript ) is a sequence of javascript statements.
Each statement is executed by the browser in the sequenced it is written
<html>
<head>
<script type="text/javascript">
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
Javascript Blocks
The purpose of a block is to make the sequence of statements executed together.
<html>
<body>
<script type="text/javascript">
{
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
}
</script>
</body>
</html>
JavaScript Comments
Javascripts comments can be added to explaine the Javascript script or to make the code more readable.
single line comments starts with //
<html>
<body>
<script type="text/javascript">
//write a heading
document.write("<h1>This is a heading</h1>");
//write two paragraphs:
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
Javascript Multiple Comments
Multiple Comments Starts with /* and end with */
<html>
<body>
<script type="text/javascript">
/* The code below will write
one heading and two paragraphs
*/
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
Using Comments to Prevent Execution
The comments is used to prevent the execution of a single code line.
<html>
<body>
<script type="text/javascript">
//document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
</script>
</body>
</html>
The comment is used to prevent the execution of a code block
<html>
<body>
<script type="text/javascript">
/*
document.write("<h1>This is a heading</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is an another paragraph</p>");
*/
</script>
</body>
</html>
Using Comments at the End of a Line
<html>
<head>
<script type="text/javascript">
document.write("hello"); //write "Hello"
document.write("Dolly");//write "Dolly"
</script>
</body>
</html>
No comments:
Post a Comment