Statements

Statements in JavaScript are usually terminated by a semicolon. A semicolon is not required but recommended.

 
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
  <script type="text/javascript">
      var firseName = 'firseName';
      var thisIsAnotherVariable = 'this Is Another Variable';
    document.writeln(firseName);
    document.writeln(thisIsAnotherVariable);
  </script>
</head>
<body>
</body>
</html>
  
Click to view the demo

Multiple statements can be combined into a code block by using C-style syntax({}):

 
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
  <script type="text/javascript">
        var i = 4;
        if (i > 5){
            alert("Greater than 5.");    
        } else {
            alert("Less than or equal to 5.");
        }

    
  </script>
</head>
<body>
</body>
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    Language Basics  

Language Basics:
  1. Case-sensitivity
  2. Identifiers
  3. Comments
  4. Strict Mode
  5. Statements
  6. Keywords And Reserved Words
  7. Variables