| 1 | <h2>Full example</h2> |
| 2 | <pre><code class="language-javascript">/** |
| 3 | * @typedef {object} Foo |
| 4 | * @property {string} bar |
| 5 | * @memberof Baz |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Trims the given string. |
| 10 | * |
| 11 | * @param {string} [str=""] the string. |
| 12 | * @returns {string} the trimmed string. |
| 13 | * @throws {TypeError} if the argument is not a string. |
| 14 | * @example trim(" hello ") |
| 15 | */ |
| 16 | function trim(str = "") { |
| 17 | if (typeof str != "string") { |
| 18 | throw new TypeError("str has to be a string"); |
| 19 | } |
| 20 | return str.trim(); |
| 21 | }</code></pre> |