Last active
February 10, 2018 13:30
-
-
Save k1r0s/3676a355648c523dda1aeafd9ccaf327 to your computer and use it in GitHub Desktop.
OOP tricks in ES5 using kaop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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