Javascript 如何使用可重复的参数指示多个类型参数? /** *返回传递给函数的所有数字的总和。 *@example *总和([1,2,3]) *//返回6 *总和(1,2,3) *//返回6 *@param{number[]|…number}params-??? */ 函数和(参数){ var args=params instanceof Array?params:arguments; 对于(变量i=0,总和=0;i
“params”可以是数组或可重复的数字 但是“@param{number[]|…number}”不起作用 书面文档输出与“@param{number[]|number}”没有差异Javascript 如何使用可重复的参数指示多个类型参数? /** *返回传递给函数的所有数字的总和。 *@example *总和([1,2,3]) *//返回6 *总和(1,2,3) *//返回6 *@param{number[]|…number}params-??? */ 函数和(参数){ var args=params instanceof Array?params:arguments; 对于(变量i=0,总和=0;i,javascript,jsdoc,Javascript,Jsdoc,“params”可以是数组或可重复的数字 但是“@param{number[]|…number}”不起作用 书面文档输出与“@param{number[]|number}”没有差异 在这种情况下,哪种方法最好?技巧是使用括号。我用了下面的方法 /** * Returns the sum of all numbers passed to the function. * @example * sum([1,2,3]) * //returns 6 * sum(1,2,3) * //retu
在这种情况下,哪种方法最好?技巧是使用括号。我用了下面的方法
/**
* Returns the sum of all numbers passed to the function.
* @example
* sum([1,2,3])
* //returns 6
* sum(1,2,3)
* //returns 6
* @param {number[]|...number} params - ???
*/
function sum(params) {
var args = params instanceof Array ? params : arguments;
for (var i = 0, sum = 0; i < args.length; i++)
sum += args[i];
return sum;
}
已更新参数名称,这应适用于:
我找不到任何关于括号的文档,但是在JSDOC3.4.2下,这就完成了
这一评论:
* @param {...(number[]|number)} params - ???
生成此文档:
希望有帮助
* @param {...(number[]|number)} params - ???
/**
* Select columns manually.
* @param {...(object|string)} col - An optional set of columns to select.
* Each argument can either be a fully-qualified column name in the form
* <table-alias>.<column-name>, or an object with the following
* properties below. If no columns are specified, then all columns are
* selected.
* @param {string} col.column - The fully-qualified column name.
* @param {string} col.mapTo - The name of the property that the column
* should be mapped to in the resulting normalized object. @param
* @param {function} col.convert - A converter function that takes a single value
* from the database and transforms it. For example, a function that
* converts a bit from the database to a boolean value.
* @return {this}
*/