TreeviewCopyright © aleen42 all right reserved, powered by aleen42

@augments Back

This tag is the same with @extends

The @augments or @extends tag indicates that a symbol inherits from, and potentially adds to, a parent symbol. It can be used to document class-based and prototype-based inheritance.

1. Prototype-based Inheritance

/**
 * Animal
 * @constructor
 */
function Animal() {
    this.alive = true;
}

/**
 * Horse
 * @constructor
 * @extends Animal 
 */
function Horse() {
    this.name = 'horse';
}

Horse.prototype = new Animal();
Horse.prototype.speak = function() { this.alive && console.log(this.name); };

2. Class-based Inheritance

/**
 * Animal
 * @class 
 */
class Animal {
    constructor() {
        this.alive = true;
    }
}

/**
 * Horse
 * @class
 * @extends Animal 
 */
class Horse extends Animal {
    constructor() {
        super();
        this.name = 'horse';
    }

    speak() { this.alive && console.log(this.name); }
}
Empty Comments
Sign in GitHub

As the plugin is integrated with a code management system like GitLab or GitHub, you may have to auth with your account before leaving comments around this article.

Notice: This plugin has used Cookie to store your token with an expiration.