Guest User

Untitled

a guest
Aug 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. class AutoBindMethod {
  2. constructor () {
  3. Object.getOwnPropertyNames(this.constructor.prototype).forEach(m => {
  4. this[m] = this[m].bind(this)
  5. })
  6. }
  7. }
  8.  
  9. class Demo extends AutoBindMethod {
  10. constructor () {
  11. super()
  12. document.addEventListener('click', this.hello)
  13. }
  14. hello () {
  15. console.log(this)
  16. }
  17. }
  18.  
  19. new Demo()
Add Comment
Please, Sign In to add comment