# return value

{% tabs %}
{% tab title="💾 程式" %}
{% hint style="success" %}
syntax：<mark style="color:yellow;">`@returns [{type}] [description]`</mark>
{% endhint %}

```javascript
/**
 * ⭐️ with a "type"
 * @returns {number}
 *
 * ⭐️ with a "type" and "description"
 * @returns {number} Sum of a and b
 */
function sum(a, b) {
    return a + b;
}

/**
 * ⭐️ with "multiple types"
 * @returns {(number|Array)} `a+b` or `[a, b, a + b]`
 */
function sum(a, b, returnArray) {
    if (returnArray) { return [a, b, a + b] }
    return a + b;
}

/**
 * ⭐️ Returns a "promise"
 * @returns {Promise} Promise object represents the sum of a and b
 */
function sumAsync(a, b) {
    return new Promise(function(resolve, reject) {
        resolve(a + b);
    });
}
```
{% endtab %}

{% tab title="📘 手冊" %}
* JSDoc ⟩ [return value](https://jsdoc.app/tags-returns.html) (<mark style="color:yellow;">`@returns`</mark>)
{% endtab %}
{% endtabs %}
