Posts

Showing posts from March, 2015

JavaScript Coding Guidelines

JavaScript Program Coding Guidelines: Always declare variable using var keyword, except when intentionally creating a global variable. //var name=”Dhanik”; Always use semicolons at the end of statement. So that when minification will be done there will no lose of functionality. Constants should be uppercase, with each word separated by an underscore. // var PI=2.147; Functions, variables, and method names all use camel case notation with the first letter lowercase. //var empFirstName=”Dhanik”; Classes and enum names also use camel case notation but with the first letter uppercase. There should be proper spacing between statements. Use tabs to indent code. Don’t use white spaces at the end of lines and empty lines should not have spaces either. Below example illustrates the preferred spacing. if ( name === “Dhanik” ) { methodCall( “see”, “our”, “spacing” ); } Use proper comments. ...