Your final superclass is always Object, so it makes no sense to try to extract it. You need to find out if the instance in question is an instance of something else using the 'is' keyword. I am writing this from the perspective of ActionScript-3, so I'm not sure what the syntax is in ES-6, but it should be in the lines of "if (this Shape)". This will return true if the instance in question extends the class you are talking about, false otherwise.
However, what you are asking for is where the Shape is separated from the standard library or standard object, and the compiler or runtime cannot figure it out. Theoretically, it would be nice if ECMA languages โโcould give you a backward inheritance array for a given class, but AFAIK, which is not and has never been a function. Without a complete chain of inheritance, you need to know which superclass you are looking for, or you cannot get it in any logical way.
source share