且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JavaScript中代码注释的正确方法是什么

更新时间:2022-06-18 04:31:02

使用//优于/* */,因为这样您就可以使用后者删除包含其他注释的整个块.但是,如果要使用自动文档生成工具,则必须使用类似于javaDoc样式的注释.

using // is better than /* */ because then you can use the latter to take out an entire block containing other comments. However, if you want to use an automatic documentation generation tool, you must use comments similar to javaDoc style.

这是一个可以与YUI DOC(***的)一起使用的示例. https://yui.github.io/yuidoc/

This is an example that would work with YUI DOC (best one) https://yui.github.io/yuidoc/

/**
* This is a description
* @namespace My.Namespace
* @method myMethodName
* @param {String} some string
* @param {Object} some object
* @return {bool} some bool
*/