Abstract

A class marked as abstract is designed to be extended upon and cannot be instantiated. Once one property is declared abstract, the entire class becomes abstract as well. An abstract method only needs to define a signature and should not include any functionality.

var Base = Class({ abstract: true }, {
    'abstract public login(string, string)' : function (user, pass) {}
});

// Throws an error: An abstract class cannot be instantiated.
new Base();

var Child = Class({ extends: Base }, { /* ... */ });

// Throws an error: Missing abstract member implementation of "login".
new Child();

var Child = Class({ extends: Base }, {
    'public login(string)' : function (user) {
        // Do stuff ...
    }
});

// Also throws an error: Missing abstract member implementation of "login", since the function signature doesn't match.
new Child();

// ...
var Child = Class({ extends: Base }, {
    'public login(string, string)' : function (user, pass) {
        // Do stuff ...
    }
});

// OK.
new Child();