Learning JavaScript tutorial – JavaScript Statements
A JavaScript program is simply a sequence of one or more JavaScript statements. JavaScript Statements is used to define the logic to make something happen. A statement can be used to declare a variable and assign a value. A statement can also be a function call, i.e. document.write(). JavaScript Statements are separated from each other with semicolons. The semicolon is optional in JavaScript, if you place each JavaScript statement on a separate line, JavaScript allows us to leave out the semicolons. The best practice of defining JavaScript Statements is to use semicolons, everywhere at the end of the each JavaScript statement.
JavaScript Statement Blocks
JavaScript Statement Block use Curly braces – {} to group a series of JavaScript Statements together to perform some sort of operation repeatedly or once based on desire condition. Whenever a JavaScript Statement Block occurs in JavaScript program is treated as a single statement. JavaScript Statement Block plays an important role while dealing with Conditional and Loop Statements.
<script type="text/javascript">
var iCount=0;
var iSum=0;
while(iCount<=5){
iSum=iSum+iCount;
iCount++;
}
alert(iSum); //alert 15
</script>




