![](/img/trans.png)
[英]How can I add description to Facebook like button using JavaScript?
[英]How can I add a description to a function in javascript?
VSCode 和大多数 IDE 一样,会自动处理JSDoc注释。 例如:
/**
* Does something nifty.
*
* @param whatsit The whatsit to use (or whatever).
* @returns A useful value.
*/
function nifty(whatsit) {
return /*...*/;
}
这是在 VSCode 中使用 function 的截图:
如果你想要类型提示,你可以用类型来增加它:
/**
* Does something nifty.
*
* @param {number} whatsit The whatsit to use (or whatever).
* @returns {string} A useful value.
*/
function nifty(whatsit) {
return /*...*/;
}
如果您使用 TypeScript,则类型将是代码的一部分,而不是 JSDoc 中:
// TypeScript example
/**
* Does something nifty.
*
* @param whatsit The whatsit to use (or whatever).
* @returns A useful value.
*/
function nifty(whatsit: number): string {
return /*...*/;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.