Essay writing maintainable JavaScript- (b)

First, a comment

  1, single-line comments

    a) begins with two slashes to the end of the bit line

    b) exclusive comment line, serve to explain the next line of code,

    c) there is always a blank line before the comment line

    d) the next line of code indentation level consistent

    e) the end of the comment line of code, the code to the end of at least between a retracted Notes

    f) if the end of the line is placed in more than 80 characters in the comment should be placed above the current code line

    g) Comment out large sections of code can be used when a continuous single-line comment, multi-line text annotation can not be used in continuous single-line comments

  2, multi-line comments

    a) begin with / * to * / end

    b) before the multi-line comment appears in the code segment to be described

    Similar c) and other methods using a single row

  3, the use of annotations

    a) add comments when the code is not clear

    b) code is difficult to understand

    c) it might be mistaken for an error code

Second, statements and expressions

  1. If two ways for writing and for statements like: brace wrapped in multiple lines of code, without braces wrapped single line of code

  2, preparation of specifications in either single-line or multi-line, multi-block and some statements should be wrapped in braces

  3, braces alignment: ① brace to prevent the block on the end of the statement block statement ② brace the first sentence of the next line of code is the first line

  4, spacer block statement: before and after the interval ② ① no spaces before a right parenthesis after the left parenthesis and add a space around a respective bracket ③ add a space

Third, variables, functions and operators

  1, the statement all variables are declared in advance to the top where the effect on the

  2, as far as possible to declare a function before calling

  3, a block of statements does not function declaration should appear

  4, function calls written, does not recommend the use of space, to distinguish it and block statements

  5, the function to be performed immediately wrapped up with a pair of parentheses, in order to see an immediate execution of the function

  6, it is best not to use strict mode in the global scope (use strict)

Guess you like

Origin www.cnblogs.com/wyongz/p/11276992.html