Skip to content

Instantly share code, notes, and snippets.

@onionmk2
Created December 18, 2016 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onionmk2/f87956b2848f93a2913b8d32fbbe60b6 to your computer and use it in GitHub Desktop.
Save onionmk2/f87956b2848f93a2913b8d32fbbe60b6 to your computer and use it in GitHub Desktop.
class ObjectInspector {
constructor(target) {
this.target = target;
this.valueOf = {
"[[Class]]": Object.prototype.toString.call(this.target),
constructorName: this.target.constructor ? this.target.constructor.name : undefined,
props: Object.getOwnPropertyNames(this.target)
}
}
}
function inspect(obj) {
let inspector = new ObjectInspector(obj);
console.dir(inspector);
if (obj.__proto__ !== null) {
inspect(obj.__proto__);
}
}
// how to use
inspect({something: 'I want to inspect this'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment