Skip to content

Instantly share code, notes, and snippets.

@zerobias
Created May 18, 2017 15:02
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 zerobias/f515c37fd9721188be4973e5adcdb67f to your computer and use it in GitHub Desktop.
Save zerobias/f515c37fd9721188be4973e5adcdb67f to your computer and use it in GitHub Desktop.
Print prototype stack
function pps (obj) {
let count = 1
while (obj) {
const okeys = Object.keys(obj)
const str = okeys.length > 0 ?
`[${okeys.join(', ')}]` : `[${obj.constructor.name}]`
console.log(`[${count++}]: ${str}`)
obj = Object.getPrototypeOf(obj)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment