JavaScript Conventions

Case Sensitivity

JavaScript is a case sensitive language. This mean that the language keywords, variables, function names and any other identifier must always be typed with a consistent capitalization of letters.

For example:
The while keyword must be type "white" and not "White" or "WHITE".

White-space and line Breaks.

Javascript ignores spaces, tabs, and newlines that appears between tokens in the program, except those that are part of string constant.

As one can use spaces, tabs and new lines in JavaScript code, it enables a user to freely format and indent the program in a neat and consistent mannner. It makes the easy to read and understandable.

Use of Semicolon

It is possible to put several statement on the same line but then must be separted with a Semicolen (;).

Also add Semicolon at the end of a statement that occupies its own line.

Example
document.write ("Hello"); alert ("World");

document.write ("Hello"); alert ("World");

Leave a Reply