Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created February 10, 2020 23:37
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 prof3ssorSt3v3/b0ef34fe99bd7448da0be4a45f2273a2 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/b0ef34fe99bd7448da0be4a45f2273a2 to your computer and use it in GitHub Desktop.
let log = console.log;
let myObj = {}; // new Object()
// log(myObj.constructor); // function Object(){}
// log(myObj.__proto__ === myObj.constructor.prototype);
function Cat() {
//constructor for kitty
}
let kitty = new Cat();
// log(kitty.__proto__ === Cat.prototype);
// log(kitty.__proto__.__proto__ === Object.prototype);
// log(Object.prototype.__proto__);
function Animal() {}
Object.setPrototypeOf(Cat.prototype, Animal.prototype);
log(kitty.__proto__); // Cat{}
log(kitty.__proto__.__proto__); // Animal {}
log(kitty.__proto__.__proto__.__proto__); // {}
log(kitty.__proto__.__proto__.__proto__.__proto__); // null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment