Why Semicolon in JavaScript 4

Why every statement level we are giving semicolon in Java Script ?
In programming language it is compulsory to write semicolon but in Scripting it is not compulsory.

If I executed with semicolon Perfectly executed :

<!doctype html>
<body>
    <pre>
<script type="text/javascript" language="javascript">
     document.write("JavaScript");
     document.write("Coding Atharva");
    </script>
    </pre>
</body>

Output:


If I executed without semicolon Perfectly executed :

<!doctype html>
<body>
    <pre>
<script type="text/javascript" language="javascript">
     document.write("JavaScript")
     document.write("Coding Atharva")
    </script>
    </pre>
</body>

Output:


Note: No Change in the Output


So Why Semicolon 

<!doctype html>
<body>
    <pre>
<script type="text/javascript" language="javascript">
     document.write("JavaScript") document.write("Coding Atharva")
    </script>
    </pre>
</body>

Output:


When we write like this JavaScript interpreter unable to understand if you are writing two statement side by side. In this case you must need to separate by semicolon.

<!doctype html>
<body>
    <pre>
<script type="text/javascript" language="javascript">
     document.write("JavaScript");document.write("Coding Atharva")
    </script>
    </pre>
</body>

Output:


Previous
Next Post »