Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AutoBindMethod {
- constructor () {
- Object.getOwnPropertyNames(this.constructor.prototype).forEach(m => {
- this[m] = this[m].bind(this)
- })
- }
- }
- class Demo extends AutoBindMethod {
- constructor () {
- super()
- document.addEventListener('click', this.hello)
- }
- hello () {
- console.log(this)
- }
- }
- new Demo()
Add Comment
Please, Sign In to add comment