JSDoc is a code documentation and commenting system widely used in modern JavaScript.

A more robust solution is to use TypeScript. It has a more coherent type system, doesn’t have IDE-specific behaviour, and largely supersedes the features provided by JSDoc.

Quick links:

Anatomy

Basic anatomy:

  • All JSDoc comments start with a /**. They are otherwise regular block comments.
  • Tags are used to denote extra properties. They can be put in front of variables, functions, or exist in their own right.
/**
* Description of the function.
*
* @param {type1} param1 description of param1
* @returns {type2}
*/
function func(param1)

Optional parameters are denoted with square brackets around their name:

/**
* @param {string} mandatoryParam
* @param {string} [optionalParam]
*/

Tags

Assume all tags are prefixed with a @.