jc

JavaScript Class method

npm install jc

jc

JavaScript Class method

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;
    },

});
npm loves you