You are here: JAVAScript/syntax

JavaScript statements are separated by semicolons(;) and ignores spaces, tabs, and newlines that appear in the JavaScript code.
Because we can use spaces, tabs, and newlines freely in your program so we are free to format and indent your programs that makes program readability.

Semicolons are Optional:
Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, C# and Java. JavaScript, however, allows you to omit this semicolon if your statements are each placed on a separate line. For example, the following code is written without semicolons


<script language="javascript" type="text/javascript">
var var1 = 10 
var var2 = 20 

But when we want to two or more statemet in one list must seperate by semicolons as:

<script language="javascript" type="text/javascript">
var var1 = 10; var var2 = 20; 

Note: It is a good programming practice to use semicolons.

Case Sensitivity:
JavaScript is a case-sensitive language. This means that language keywords, variables, function names, and other identifiers must be keep in mind capitalization of letters.
So identifiers niceTime, niceTIme and NiceTIME will have different meanings in JavaScript.
NOTE: Care should be taken while writing your variable and function names in JavaScript.

Comments in JavaScript:
JavaScript supports both C-style and C++-style and C#-style comments, Thus:

  • Any text written after a // to the end of a line is treated as a comment and is ignored by JavaScript.
  • Any text written between the characters /* and */ is treated as a comment. This may span multiple lines.
  • JavaScript also recognizes the HTML comment opening sequence <!-- and treats this as a single-line comment, just like the // comment.
  • But the HTML comment closing sequence --> is not recognized by JavaScript so it should be written as //-->.


<script language="javascript" type="text/javascript">
// This is a comment. It is similar to comments in C++, C#
* This is a multiline comment in JavaScript
* It is very similar to comments in C Programming


Active User (0)

No Active User!
 Log In to Chat