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