Skip to content

Instantly share code, notes, and snippets.

@martinkuba
Created September 25, 2017 03:44
Show Gist options
  • Select an option

  • Save martinkuba/11db7b3cadba746eb60825722c04893a to your computer and use it in GitHub Desktop.

Select an option

Save martinkuba/11db7b3cadba746eb60825722c04893a to your computer and use it in GitHub Desktop.
inspect object
// 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