The constructor
property can be gotten by referencing it explicitly, or by iterating over all properties of the object (not just enumerable properties), with Object.getOwnPropertyNames
.
The [[Prototype]]
property is equivalent to the value returned by Object.getPrototypeOf
, so you can call that to access the prototype object and iterate through it too, if you want.
Perhaps something like:
const recursiveLogAllProperties = (obj) => {
Object.getOwnPropertyNames(obj).forEach(prop => console.log(prop, obj[prop]));
const proto = Object.getPrototypeOf(obj);
if (proto === Object.prototype) return;
console.log('------ Prototype:');
recursiveLogAllProperties(proto);
}
const arr = [1, 2];
recursiveLogAllProperties(arr);
The [[Scopes]]
internal property is not accessible from JavaScript.