When exploring an object using a tree structure in the browser console, you can inspect it like this:
console.log(document);
You can navigate through the object, including its prototype and subsequent prototypes. I attempted to replicate this feature but encountered an issue with logging the "prototype of prototype."
My code successfully retrieves the keys within the prototype, but encounters an error when trying to log them (using var
for easier testing in the console). Here is a simplified version demonstrating the problem:
var prototype = Object.getPrototypeOf(document);
var prototypeOfPrototype = Object.getPrototypeOf(prototype);
// Accessing the keys works fine
var keys = Object.getOwnPropertyNames(prototypeOfPrototype);
console.log(keys);
var values = keys.map((key) => {
// An error occurs here even though there should be no execution
console.log(prototypeOfPrototype[key]);
});
The errors I'm receiving are as follows:
Chrome:
"Illegal invocation"
Firefox:
"Uncaught TypeError: 'get implementation' called on an object that does not implement interface Document."
These errors aren't very informative to me. If anyone has insights into why this is happening or how to implement this feature without encountering the error, I would greatly appreciate it.