title: Jsdoc
category: JavaScript
layout: 2017/sheet
-updated: 2019-01-10
+updated: 2020-06-23
weight: -1
---
* This is a function.
*
* @param {string} n - A string param
+ * @param {string} [o] - A optional string param
+ * @param {string} [d=DefaultValue] - A optional string param
* @return {string} A good string
*
* @example
* foo('hello')
*/
-function foo(n) { return n }
+function foo(n, o, d) {
+ return n
+}
```
-See: <http://usejsdoc.org/index.html>
+See: <https://jsdoc.app/index.html>
### Types
-| Type | Description |
-| --- | --- |
-| `@param {string=} n` | Optional |
-| `@param {string} [n]` | Optional |
-| `@param {(string|number)} n` | Multiple types |
-| `@param {*} n` | Any type |
-| `@param {...string} n` | Repeatable arguments |
-| `@param {string} [n="hi"]` | Optional with default |
-| `@param {string[]} n` | Array of strings |
+| Type | Description |
+| ------------------------------- | ------------------------------------- |
+| `@param {string=} n` | Optional |
+| `@param {string} [n]` | Optional |
+| `@param {(string|number)} n` | Multiple types |
+| `@param {*} n` | Any type |
+| `@param {...string} n` | Repeatable arguments |
+| `@param {string} [n="hi"]` | Optional with default |
+| `@param {string[]} n` | Array of strings |
| `@return {Promise<string[]>} n` | Promise fulfilled by array of strings |
-See: <http://usejsdoc.org/tags-type.html>
+See: <https://jsdoc.app/tags-type.html>
### Variables
* @param {Song} song - The {@link Song} to be played
*/
-function play (song) {
-}
+function play(song) {}
```
-See: <http://usejsdoc.org/tags-typedef.html>
+See: <https://jsdoc.app/tags-typedef.html>
### Typedef Shorthand
+{% raw %}
+
```js
/**
* A song
*/
```
+{% endraw %}
+
```js
/**
* Plays a song
* @param {Song} song - The {@link Song} to be played
*/
-function play (song) {
-}
+function play(song) {}
```
-See: <http://usejsdoc.org/tags-typedef.html>
+See: <https://jsdoc.app/tags-typedef.html>
### Importing types
* @param {Bar} x
*/
-function test(x) { }
+function test(x) {}
```
This syntax is [TypeScript-specific](https://github.com/Microsoft/TypeScript/wiki/JsDoc-support-in-JavaScript#import-types).
```js
/**
* @throws {FooException}
+ * @async
* @private
* @deprecated
* @see
*/
```
+See the full list: <https://jsdoc.app/index.html#block-tags>
+
### Renaming
```js
*/
```
-Prefer `alias` over `name`. See: <http://usejsdoc.org/tags-alias.html>
+Prefer `alias` over `name`. See: <https://jsdoc.app/tags-alias.html>