Created
September 25, 2017 03:44
-
-
Save martinkuba/11db7b3cadba746eb60825722c04893a to your computer and use it in GitHub Desktop.
inspect object
This file contains hidden or 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
| // show properties | |
| for (var key in obj) { | |
| console.log(key) | |
| var val = obj[key] | |
| if (!val) { | |
| val = '** undefined **' | |
| } else if (typeof val === 'object') { | |
| val = '** function **' | |
| } else if (typeof val === 'function') { | |
| val = '** object **' | |
| } | |
| console.log(val) | |
| } | |
| // show prototype chain | |
| while (obj) { | |
| if (obj.constructor) { | |
| console.log(obj.constructor.name) | |
| } | |
| obj = Object.getPrototypeOf(obj) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment