- ES6 and ES7 friendly, through semantic
extends
andconstructor
plus other features - ES5 natively compatible granting that what you write is what you get
- ES3 backward compatible, thanks to common minifiers that will make production code safe
Feel free to test all features related to this project, and please come back if your browser is not green.
Following a list of tested browsers split in Desktop and Mobile.
- Chrome
- Firefox
- IE 6 or greater
- Safari
- Opera
- Android 2 or greater
- iOS 5 or greater
- IE9 Mobile or greater
- Bada
- Kindle Fire
- Xpress
- Opera Mini and Mobile
All features explained in the dedicated page.
Following a summary:
- constructor to optionally define the implicit initializer per each instance
- extends to optionally define a class or an object to inherit from
- super to shortcut super methods invocation
- with to attach lightweight traits / mixins enabling composition behind optional initializers per each mixin
- static to define public static class constants, inherited if extended, without ever polluting the prototype
- implements to perform light checks over expected implementations and warn eventually when something is missing
This is an example of what's possible:
var Engineer = Class({
constructor: function (name, age, type) {
this.super(name, age);
this.type = type;
},
extends: Person,
with: [
eventEmitter,
growingEachYear,
carrierPath
],
static: {
SOFTWARE: 0,
CONSTRUCTIONS: 1
},
implements: [
iWorker
]
});
var me = new Engineer(
'Mr. Andrea Giammarchi',
36,
Engineer.SOFTWARE
);
me instanceof Person; // true
me.type; // Engineer.SOFTWARE
me.emit('work:start', {
tasks: ['do this', 'do that']
});