Created
December 18, 2016 14:26
-
-
Save onionmk2/f87956b2848f93a2913b8d32fbbe60b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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