只是好奇什么是评论将哪些参数传递给回调函数的好方法.
假设我们有以下代码和不完整的注释
- /**
- * an utterly useless function
- *
- * @param {String} an useless string
- * @param {Boolean} an useless boolean
- * @param {Function} ???
- */
- function Useless (str,bool,callback) {
- callback(str,bool);
- }
解决方法
通常,您只需使用发言名称编写函数调用:
- /*
- * @param {String} input: the text
- * @param {Function} callback(output,hasChanged): called after calculation
- */
或者,如果参数需要说明,您可以使用多行描述:
- /*
- * @param {String} input: the text
- * @param {Function} callback(result,change)
- * the function that is called after calculation
- * result {String}: the output of the computation
- * change {Boolean}: whether a change has occurred
- */