I would like to add a description to a js function like I do it in C, C++, Python ...
I do this by adding a comment at the top of the definition of the function, in the mentioned languages, but if I use JavaScript (pure, NodeJS, ReactJS) it does not show it. Ej:

Result (When I put the cursor in a call of the function or definition):

But I this behaviour does not replicate with Js/NodeJs/React. Just in case I'm using Visual Studio Code.
VSCode, like most IDEs, will automatically process JSDoc comments. For example:
/**
* Does something nifty.
*
* @param whatsit The whatsit to use (or whatever).
* @returns A useful value.
*/
function nifty(whatsit) {
return /*...*/;
}
Here's a screenshot of what using that function is like in VSCode:

You can augment that with types if you want type hints:
/**
* Does something nifty.
*
* @param {number} whatsit The whatsit to use (or whatever).
* @returns {string} A useful value.
*/
function nifty(whatsit) {
return /*...*/;
}
If you use TypeScript, the types would be part of the code rather than in the JSDoc:
// TypeScript example
/**
* Does something nifty.
*
* @param whatsit The whatsit to use (or whatever).
* @returns A useful value.
*/
function nifty(whatsit: number): string {
return /*...*/;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With