Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
Is there a convention for specifying the author, date, or source of code in JavaScript?

I would like to specify the sources of foreign functions (for example here from StackOverflow 🤓). Also I would like to add my name, date and website to my own functions.

I can of course just put everything in a comment the way I want. But are there certain conventions I should follow? Maybe even machine readable?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

JSDoc is usually used to specify metadata for javascript code, and can be used to automatically generate documentation. See: https://jsdoc.app/about-getting-started.html

Example:

/**
 * @author Some Guy <example@example.com>
 * @see {@link https://jsdoc.app/tags-description.html} for further information.
 * @description How to use JSDoc to tag javascript.
 */
about 4 years ago · Juan Pablo Isaza Report

0

There is no official way to specify this. At least no One True Way.

With that said, the most widely accepted is JSDoc comments. You need to start a block comment with /** (two asterisks) and then you can use the special JSDoc syntax to explain your source with @author and @see:

/**
 * Function that returns a random number
 * @author Jon Skeet
 * @see {@link https://stackoverflow.com/a/11373465}
 * 
 * @param {number} min - minimum bound (inclusive)
 * @param {number} max - maximum bound (inclusive)
 * @return {string} - uniformly distributed integer within the range as a string 
 */
function rand(min, max){
   return (Math.floor(Math.random() * (max - min + 1)) + min).toFixed(0);
}

Maybe even machine readable?

JSDoc is machine readable. There are many tools that consume it. Most notably, many standard JavaScript editors like Visual Studio Code will give you the JSDoc for a function on hover. Screenshot of code editor which shows that the JSDoc comment is shown when hovering over the function.

However, there are other tools that can consume JSDoc or subset of it. They may produce documentation, or perform type checking based on what is specified for @param and @return, or other tasks.

It is also worth noting that you do not need to have any tool in order to use JSDoc. You can write it directly in your source code even if it does not get consumed ever. It can still be read by other humans who would understand it. Even if it is the first time they encounter the documentation style, it is straight-forward enough to be easily understood.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!