Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Test {
- setPoints() {
- this.x = 20;
- this.y = 40;
- }
- getPoints() {
- const { x, y } = this;
- return { x, y };
- }
- }
- class SubTest extends Test {
- // Override class method, call base class method using super
- // setPoints() {
- // super.setPoints();
- // this.x = 10;
- // }
- }
- SubTest.prototype.originalSetPoints = SubTest.prototype.setPoints;
- SubTest.prototype.setPoints = function () {
- this.originalSetPoints();
- this.x = 10;
- };
- const test = new SubTest();
- test.setPoints();
- console.log(test.getPoints());
Add Comment
Please, Sign In to add comment