Skip to content

Instantly share code, notes, and snippets.

@imskojs
Created January 10, 2019 00:23
Show Gist options
  • Save imskojs/53eb82b3bedf4250684881b93bb90148 to your computer and use it in GitHub Desktop.
Save imskojs/53eb82b3bedf4250684881b93bb90148 to your computer and use it in GitHub Desktop.
// Returns All prototypical chain of an object.
function protos(obj) {
var result = [];
function diver(obj){
if(obj.__proto__){
result.push(obj.__proto__);
} else {
return false;
}
diver(obj.__proto__);
}
diver(obj);
return result;
}
// Example;
var x = [];
var y = protos(x);
console.dir(y) // output: [Array, Object]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment