Guest User

Untitled

a guest
Feb 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class Test {
  2. setPoints() {
  3. this.x = 20;
  4. this.y = 40;
  5. }
  6. getPoints() {
  7. const { x, y } = this;
  8. return { x, y };
  9. }
  10. }
  11.  
  12. class SubTest extends Test {
  13. // Override class method, call base class method using super
  14. // setPoints() {
  15. // super.setPoints();
  16. // this.x = 10;
  17. // }
  18. }
  19.  
  20. SubTest.prototype.originalSetPoints = SubTest.prototype.setPoints;
  21. SubTest.prototype.setPoints = function () {
  22. this.originalSetPoints();
  23. this.x = 10;
  24. };
  25.  
  26. const test = new SubTest();
  27.  
  28. test.setPoints();
  29. console.log(test.getPoints());
Add Comment
Please, Sign In to add comment