Skip to content

Instantly share code, notes, and snippets.

@k1r0s
Last active February 10, 2018 13:30
Show Gist options
  • Save k1r0s/3676a355648c523dda1aeafd9ccaf327 to your computer and use it in GitHub Desktop.
Save k1r0s/3676a355648c523dda1aeafd9ccaf327 to your computer and use it in GitHub Desktop.
OOP tricks in ES5 using kaop
const { createClass, extend, override } = require('kaop');
const Person = createClass({
name: undefined,
constructor: function(name){
this.name = name;
},
sayHello: function() {
return "Hey, I'm " + this.name;
}
});
const Programmer = extend(Person, {
constructor: [override.implement, function(_super, name) {
_super(name);
// do stuff
}],
code: function() {
return this.sayHello() + " and I code";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment