Last active
May 9, 2016 22:44
-
-
Save pmcao/c13212db0a40e6ff4509539fa37bf8d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// classA.ts | |
export class A { | |
a:string; | |
} | |
// app.ts | |
class C extends B { | |
c:string; | |
whoAmI() { | |
let t = Object.getPrototypeOf(this); | |
let base: string = ""; | |
console.log("Traversing class hierarchy..."); | |
while (t.constructor.name !== "Object"){ | |
console.log(t.constructor.name); | |
base = t.constructor.name; | |
t = Object.getPrototypeOf(t); | |
} | |
console.log("Base is class " + base); | |
} | |
foo (x:XX,y:YY) { | |
for (var arg in arguments){ | |
console.log(arguments[arg]); | |
} | |
} | |
} | |
var c = new C(); | |
c.whoAmI(); | |
var x = new XX(); | |
var y = new YY(); | |
c.foo(x, y); | |
// Output: | |
Traversing class hierarchy... | |
C | |
B | |
A | |
Base is class A | |
XX {} | |
YY {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment