jc
v0.0.1
Published
JavaScript Class method
Downloads
241
Readme
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;
},
});