Skip to content
nene edited this page Mar 10, 2013 · 8 revisions

Synopsis:

@return {Type}
Some description...

@return {Type} return.subproperty
Some description...

Documents the return value of a method. You can either use @return or @returns.

For constructors the return type defaults to the class where the constructor belongs, otherwise it defaults to undefined which means the return value is not shown in documentation.

Returning object

To document properties of the object that is returned, use the following syntax:

/**
 * @return {Object} A user record
 * @return {String} return.name The name of the user.
 * @return {String} return.email The email of the user.
 */
function getUser() {
}

Returning this

Methods always returning this should be labeled with @chainable.

Returning function

When returning a function, its parameters and return value can also be documented:

/**
 * @return {Function} A predicate function that
 * determines is number is odd or even.
 * @return {Number} return.value The number to test.
 * @return {Boolean} return.return True if number is even.
 */
function createEvenPredicate() {
}

See also documentation for @param.