"Learning Notes" JavaScript coding specification-Comments

Source: Internet
Author: User
Tags tag name

Multiline comments using/**......*/, you need to include a description, a value for the specific type of all parameters, and a return value.

bad//make () returns a new element//based on the passed in tag name////@param {String} tag//@return {element} elemen Tfunction make (TAG) {//... stuff...return element;} good/*** make () returns a new element* based on the passed in tag name** @param {String} tag* @return {element} element */function make (TAG) {//... stuff...return element;}

Single-line comments use//to place a single-line comment on the previous line of the statement and a blank line before the comment.

Badvar active = true; Is current tab//good//are current tabvar active = true;//badfunction getType () {Console.log (' fetching type ... ');//SE t the default type to ' no type ' var type = This._type | | ' No type '; return type;} Good.  God bless!function GetType () {Console.log (' fetching type ... ');//Set the default type to ' no type ' var type = This._type | | ' No type '; return type;}

If you point to a problem that needs to be repositioned or a problem to be addressed needs to be implemented, adding a fixme or TODO prefix to the comment will help other developers quickly understand it. These comments are different from the usual annotations because they are available for implementation. These implementation measures are fixme--need to figure this out or TODO--need to implement.

function AAA () {//<strong> use//fixme: Comment on a question </strong>fixme:shouldn ' t uses a global heretotal = 0;return thi s;}

function BBB () {//<strong> using//todo: Commenting on the problem solution </strong>todo:total should be configurable by an options param This.total = 0;return This;}


God Bless you!


"Learning Notes" JavaScript coding specification-Comments

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.