return value

syntax:@returns [{type}] [description]

/**
 * ⭐️ 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);
    });
}

Last updated