Javascript-Common Code specification

Source: Internet
Author: User
Spec. 1: Be sure to write down global variables, and try to implement various functions, repeating code, etc. into a function.

Advantages: It helps to read and maintain. Prevent variable contamination.

Spec 2: All functions, variables, semantics. Spec. 3: Do not omit the semicolon at the end of the sentence. Specification 4: Do not use equal " = =", to use congruent "= = = "

Original: JS is a weakly typed language, and equality causes the default implicit conversions: false = = 0 = True

Spec. 5: Try to put all the variables in the first line. Such as:

var i, J, arr = [], obj = {};

Advantages:

  1. Less code.
  2. To help you remember all the variables
  3. Prevent definition before using
  4. Provide a single place to find variables
Rule 6: Do not use the new command instead of the object.create () command. Rule 7: Do not use the self-increment (+ +) and decrement (-) operators, substituting + = and-=. Rule 8: Always use curly braces to represent chunks.
if(a + b === c){    //dosomething}

Javascript-Common Code specification

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.