Tuesday, October 21, 2014

Javascript Blocks and Comments

JavaScript Blocks:

- JavaScript statements can be grouped together in blocks.
- Blocks start with a left curly bracket {, and ends with a right curly bracket }.
- The purpose of a block is to make the sequence of statements execute together.
<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 another paragraph.</p>");
}
</script>
- Normally a block is used to group statements together in a function or in a condition   
(where a group of statements should be executed if a condition is met).

Comments in JavaScript:
- JavaScript comments can be used to make the code more readable.
- Comments can be added to explain the JavaScript, or to make the code more readable.
1)Single line comments start with //.
2)Multi line comments start with /* and end with */.
3)The following example uses a multi line comment to explain the code:


1 comment:

Kale Co Jakim said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai