node. JS Encoding Specification

Source: Internet
Author: User
Tags naming convention

When calling a function, there is no space between the function name and the opening parenthesis.

There is no space between the function name and the parameter sequence, and there is a space between all other syntax elements and the opening parenthesis.

Use the small hump-style nomenclature as a naming convention for all variables and attributes.
indents use two spaces, using single quotes uniformly.
associative arrays are not quoted unless there are spaces or illegal characters in the key name.
do not combine statements of different purposes into a single line.
do not omit the semicolon at the end of the sentence, even if the line has only one statement.
do not use the self-increment (+ +) and decrement (-) operators, instead of + = and-=.
do not use the equality (= =) operator, only the strict equality (= = =) operators.
all variable declarations are placed on the head of the function.
all functions are defined before they are used.
name the constructor and callback function as much as possible so that you can see a clearer call stack when you are debugging.
try to define all the member functions through the prototype, define the attributes within the constructor, and then create the object with the new keyword on the constructor.
Avoid complex inheritance, if you want to inherit, try to use the Inherits function in the Util module. For example, A inherits B, it can be util.inherits (A, A).


Resources:
Appendix B (byvoid) of the node. JS Development Guide

JavaScript programming Style (Nanyi)



Document Information

    • Copyright Disclaimer: Free Reprint-Non-commercial-non-derivative-retain attribution | Creative Commons by-nc-nd 3.0
    • Original URL: http://blog.csdn.net/cdztop/article/details/37749051
    • Last modified: July 14, 2014 01:50

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.