You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The @param tag (or @arg or @argument) documents a function parameter.</p>
51
-
<p>The @param tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in curly brackets,
52
-
and a description of the parameter.</p>
67
+
<p>The <code>@param</code> tag provides the name, type, and description of a function parameter.</p>
68
+
<p>The <code>@param</code> tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in
69
+
curly brackets, and a description of the parameter.</p>
53
70
<p>The parameter type can be a built-in JavaScript type, such as <code>string</code> or <code>Object</code>, or a
54
71
<ahref="about-namepaths.html">JSDoc namepath</a> to another symbol in your code. If you have written documentation for the symbol at that namepath, JSDoc
55
72
will automatically link to the documentation for that symbol. You can also use a type expression to indicate, for example, that a parameter is not nullable
56
-
or can accept any type; see the [@type documentation][tags-type] for details.</p>
73
+
or can accept any type; see the [<code>@type</code> tag documentation][tags-type] for details.</p>
57
74
<p>If you provide a description, you can make the JSDoc comment more readable by inserting a hyphen before the description. Be sure to include a space before and
58
75
after the hyphen.</p>
59
76
<h2id="examples">Examples</h2>
60
-
<p>The following examples show how to include names, types, and descriptions in a @param tag.</p>
77
+
<h3id="names-types-and-descriptions">Names, types, and descriptions</h3>
78
+
<p>The following examples show how to include names, types, and descriptions in a <code>@param</code> tag.</p>
<h3id="parameters-with-properties">Parameters with properties</h3>
117
+
<p>If a parameter is expected to have a specific property, you can document that property by providing an additional <code>@param</code> tag. For example, if an
118
+
<code>employee</code> parameter is expected to have <code>name</code> and
119
+
<code>department</code> properties, you can document it as follows:</p>
120
+
<figure>
121
+
<figcaption>Documenting a parameter's properties</figcaption><preclass="prettyprint lang-js"><code>/**
122
+
* Assign the project to an employee.
123
+
* @param {Object} employee - The employee who is responsible for the project.
124
+
* @param {string} employee.name - The name of the employee.
125
+
* @param {string} employee.department - The employee's department.
126
+
*/
127
+
Project.prototype.assign = function(employee) {
128
+
// ...
129
+
};
130
+
</code></pre>
131
+
</figure>
132
+
<p>You can also combine this syntax with JSDoc's syntax for array parameters. For example, if multiple employees can be assigned to a project:</p>
133
+
<figure>
134
+
<figcaption>Documenting properties of values in an array</figcaption><preclass="prettyprint lang-js"><code>/**
135
+
* Assign the project to a list of employees.
136
+
* @param {Object[]} employees - The employees who are responsible for the project.
137
+
* @param {string} employees[].name - The name of an employee.
138
+
* @param {string} employees[].department - The employee's department.
139
+
*/
140
+
Project.prototype.assign = function(employees) {
141
+
// ...
142
+
};
143
+
</code></pre>
144
+
</figure>
145
+
<h3id="optional-parameters-and-default-values">Optional parameters and default values</h3>
98
146
<p>The following examples show how to indicate that a parameter is optional and has a defa
DDB3
ult value.</p>
<h3id="multiple-types-and-repeatable-parameters">Multiple types and repeatable parameters</h3>
135
184
<p>The following examples show how to use type expressions to indicate that a parameter can accept multiple types (or any type), and that a parameter can be provided
136
185
more than once. See the
137
-
<ahref="tags-type.html">@type documentation</a> for details about the type expressions that JSDoc supports.</p>
186
+
<ahref="tags-type.html"><code>@type</code> tag documentation</a> for details about the type expressions that JSDoc supports.</p>
138
187
<figure>
139
188
<figcaption>Allows one type OR another type (type union)</figcaption><preclass="prettyprint lang-js"><code>/**
140
189
* @param {(string|string[])} [somebody=John Doe] - Somebody's name, or an array of names.
<p>If a parameter accepts a callback function, you can use the <ahref="tags-callback.html">@callback tag</a> to define a callback type, then include the callback
<p>If a parameter accepts a callback function, you can use the <ahref="tags-callback.html"><code>@callback</code> tag</a> to define a callback type, then include
226
+
the callback type in the <code>@param</code> tag.</p>
177
227
<figure>
178
228
<figcaption>Parameters that accept a callback</figcaption><preclass="prettyprint lang-js"><code>/**
179
229
* This callback type is called `requestCallback` and is displayed as a global symbol.
0 commit comments