Created
February 10, 2020 23:37
-
-
Save prof3ssorSt3v3/b0ef34fe99bd7448da0be4a45f2273a2 to your computer and use it in GitHub Desktop.
This file contains 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
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