0.0.1 • Published 11 years ago

jc v0.0.1

Weekly downloads
19
License
BSD
Repository
github
Last release
11 years ago

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