In this articles I have listed some very basic java script guidelines, that I believe should be considered when using java script. These are very basic guidelines and can be treated as rules:
Table of Contents
JavaScript is Case Sensitive:
Yes, that’s correct, all the syntax, variable declarations, function names etc are case sensitive. A function named “foofunction” is not the same as “FooFunction” and a variable named “thisVar” is not the same as “ThisVar”.
JavaScript is case sensitive – therefore watch your capitalization closely when you create or call variables, objects and functions.
White Space:
JavaScript does not consider extra spaces between syntaxs. You can add white space to your script to make it more readable. The following lines are equivalent:
city="Mumbai" city = "Mumbai"
Break up a Code Line:
You can break up a code line within a text string with a backslash to make it more readable. However only the text within the code cab be broken down in multiple lines and not the syntax itself. The example below will be displayed properly:
//Will work properly document.write("Technocrats\ Club!") //Will not work document.write \ ("Technocrats Club!")
Comments:
You should use comments where ever applicable. Based on the situations you can use single line or multi line comments in java script. See the below code sample for comments.
//this is a single line comment document.write("Technocrats Club!") /* This is how you can use comment multi line comments It is also know as Comments Block */ document.write("Technocrats Club!")