jc

0.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i jc

Weekly Downloads

20

Version

0.0.1

License

BSD

Last publish

Collaborators

  • teniryte