Where should we use semicolon in the statements? Is it mandatory?
Answers
we must use it at the end of each statement and it is mandatory.it is like a full stop to a sentence.if it is not there it would change the meaning.
JavaScript semicolons break the culture. Many people prefer to always use them, regardless. Others want to avoid it.
Explanation:
Automatic JavaScript Semicolon Insertion Rules When you parse source code for these particular situations, the JavaScript parser automatically adds the semicolon:
1. When the following line begins with the code which breaks the current line (multiline code can spawn).
2. When the next line starts with}, when the source code file is done, close the current row. 3. If on its own line there is a return statement.
4. If on its own line is a break declaration.
5. When on its own line is a throw declaration. 6. when on its own line is a continuous declaration .