Вы находитесь на странице: 1из 1

Javascript Programming Standards and Guidelines. Ver 1.

JavaScript Naming Guidelines: Function names should begin with a lowercase letter, and the first letter of each subsequent new word should be uppercase with all other letters lowercase. (camelCase) Example: function myFirstFunction ... !ll "ariables should be declared in first lines of code. #n addition, all "ariables must be declared in functions to $eep them local. %ariable names should begin with a lowercase letter, and the first letter of each subsequent word should be uppercase with all other letters lowercase. %ariable names should indicate their data type with a consistent prefix (bln & boolean' flt & floating point' int & integer' ob( & ob(ect' str & string).

Example : bln#s%alid , int)eight , ob(*able , strFoo .


E"ery constant "ariable name should be in upper case.

Example: const C+,-!./0.!,E 1 23healsoft4'

Spacing
Consider the following two lines:

for(x=1;x<10;x++){y+=x;alert(x);}
+r:

for ( x=1; x<10; x++ ) { y += x; alert( x ); }


!s far as readability, the second rendition is more pleasurable to read. *he terseness of the first line can be confusing to the eyes. !dditionally, it is suggested that one blan$ line should be placed before and after a function5class declaration to increase readability. *oo much of space is not recommended as it affects the performance in the client side too, howe"er marginally.

Braces
*he following two lines pro"ide a demonstration:

for ( x=1; x<10; x++ ) {


+r:

for ( x=1; x<10; x++ ) {


*he braces should be on its own line for better readability . 6o First one is recommended.

Rheal Software Pvt. Ltd.

Вам также может понравиться