JavaScript Class function
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist
lib
test
README.md
package.json

README.md

jc

JavaScript class system

Installation

npm install jc

Example

var Class = require('jc');

var Person = Class({

    // Default properties
    name: '',
    age: 0,

    // Constructor
    init: function (name, age) {
        this.name = name;
        this.age = age;
    },

    // Methods
    getInfo: function () {
        return this.name + '-' + this.age;
    },

    // Static properties
    static: {
        count: 0,
        getCount: function () {
            return this.count;
        },
    }

});

var Programmer = Class({

    // Inheritance
    extends: Person,

    // Override constructor
    init: function (name, age, language) {
        this.language = language;
    },

    // Override methods
    getInfo: function () {
        // Call super methods
        return this.super.getInfo() + '-' + this.language;
    },

});