Question

Sample code:

var myObject = (function() {
    var M;

    M = function() {
    }

    M.prototype = {
        constructor: M,
        setSomeProperty = function(someValue) {
            // Do Stuff
            return this; // For chaining purposes
        }
    }

    return M
}());

What would the @returns tag look like when documenting the setSomeProperty method?

Was it helpful?

Solution

It would look like this:

@returns {M} <code>this</code>

{M} indicates the class of what is returned, and <code>this</code> clearly indicates what is returned. If you use the markdown plugin:

@returns {M} `this`

A more verbose version would be:

@returns {M} The instance on which this method was called.

Or you could omit the class information and let the reader infer it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top