I'm currently working on Chrome.
console.log(window.__proto__.__proto__.__proto__);
console.log(window.__proto__.__proto__.__proto__ === EventTarget.prototype);
I've found that first code above returns EventTarget.prototype
This can be verified by the second code, which returns "true"
In addition, the following code also returns true:
console.log(EventTarget.prototype.__proto__ === Object.prototype);
However, problems arise when you track who the child of EventTarget.prototype is.
console.log(window.__proto__.__proto__);
Above code returns below.
WindowProperties {Symbol(Symbol.toStringTag) : "WindowProperties" .....}
When I try to track the constructor "WindowProperties()" or the object "WindowProperties.prototype",
console says
Uncaught ReferenceError: WindowProperties is not defined at :1:13
why is this happen?
Because there is no built-in global called
WindowsPropertiesexposed to your code. Just because something exists and has a name doesn't mean that your code has access to it. For instance:Note: I've used
__proto__in the code above so it would closely mirror yours, but I recommend not using__proto__in real code. UseObject.getPrototypeOf(and, if unavoidable,Object.setPrototypeOf) instead.__proto__is a deprecated feature defined in browsers only, and not all objects have it (although nearly all do; it's defined byObject.prototype).Side note: Your code got me interested in the lineage of
windowin Chrome, so I wrote the following. You may find it interesting:On Chrome that gives me:
Window WindowProperties EventTarget Object undefinedOn Firefox that gives me something slightly different:
Window EventTarget EventTarget Object undefined