Walk Constructor
by andypotanin
JavaScript
function get_constructors( context ) {
var matches = {};
do {
Object.defineProperty( matches, context.constructor.name, {
enumerable: true,
writable: true,
value: {
name: context.constructor.name,
properties: {
constructor: {
type: typeof context.constructor,
properties: Object.getOwnPropertyNames( context.constructor )
},
prototype: {
type: typeof context.constructor.prototype,
properties: Object.keys( context.constructor.prototype )
}
}
}
});
} while ( context = Object.getPrototypeOf( context ) );
return matches || {};
}
console.log( get_constructors( this ) );