Consider the following code snippet:
function a() {}
function b() {}
b.prototype = new a();
var b1 = new b();
It can be observed that a
has been incorporated into the prototype chain of b
. This demonstrates that:
b1 is an instance of b
b1 is an instance of a
b1 is an instance of Object
The main question at hand is, how can we determine the members of the prototype chain for b1
if we do not have prior knowledge about its origins? It would be ideal to obtain an array such as [b, a, Object]
or ["b", "a", "Object"]
.
Is such a task possible? I recall coming across a solution on Stack Overflow explaining this process, but unfortunately, I cannot seem to locate it again.