This question already has an answer here:
var A = class A {};
var B = class B extends A {};
var C = class C extends B {};
Given the code above assuming I only have access to class 'C', how can I know what are its ancestor classes? The correct answer of course is B then A, but how can my code tell me that?
You can iterate the prototype chain of
C.prototype
and get the prototype'sconstructor
property.