javascript code cleanup

javascript file naming: All file names should follow the same naming convention. The minus sign (-) is an excellent choice for separating filenames. File names always start with a letter, not a number. (letters lowercase)

html specification

<!DOCTYPE html>
<meta charset="utf-8">
<title>Test </title>
 

 

Not recommended:

<!DOCTYPE html>
<meta charset="utf-8">
<title>Test     

 

In this way, if the label that should not be omitted is omitted, an error will be reported. Of course, the HTML5 specification stipulates that HTML tags can be omitted. Omitting some unnecessary tags really does reduce page size.

css ID and Class naming:

ID and class names should be preferred to names that are specific and reflect the purpose of the element, as these are the most understandable. (The name reflects the purpose and purpose of the element)

If you write the code to write a <div> which contains N multiple <div>s, then the big <div> takes a name (a common name is defined for the whole block), and the small blocks inside have their own names. These are not clearly defined, but they must conform to the meaning of the information, and people will know the meaning when they see the name. Such code is highly readable. (The ID name can only be used once, and the class name can be used multiple times).

javascript 

js function names also have meaning. Add a semicolon at the end of the statement;

A return statement with a return value should not use ( ) (parentheses) to enclose the return value. An if is followed by a conditional statement.

Comment: single line comment "//"

   Multi-line comments: "/*" starts with " */ " and ends

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327067906&siteId=291194637