Skip to content

Instantly share code, notes, and snippets.

@justjavac
Last active May 24, 2017 05:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justjavac/82494287bb25cd671c781242bce975e1 to your computer and use it in GitHub Desktop.
Save justjavac/82494287bb25cd671c781242bce975e1 to your computer and use it in GitHub Desktop.
keyword super in babel and typescript
"use strict";
class Point {
getX() {
console.log(this.x); // C
}
}
class ColorPoint extends Point {
constructor() {
super();
this.x = 2;
super.x = 3;
console.log(this.x) // A
console.log(super.x) // B
}
m() {
this.getX()
}
}
const cp = new ColorPoint();
cp.m();
A B C
Chrome 3 undefined 3
babel 2 undefined 2
TypeScript 2 3 2
  • Chrome 58.0.3029.110 64bit (V8 5.8.283.38)
  • Babel Repl 6.24.2
  • TypeScript 2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment