Created
January 25, 2018 03:36
-
-
Save prof3ssorSt3v3/e48b5c43a91a8a52b724f92fc8f314b5 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
/*********************************************************** | |
// [ toString, valueOf, isPrototypeOf, hasOwnProperty,....] | |
// obj ==> obj.prototype (Object prototype) ==> null | |
Object Prototypes in JavaScript | |
***********************************************************/ | |
let obj1 = { | |
prop1: () => console.log('prop1') | |
}; | |
let obj2 = { | |
prop2: () => console.log('prop2') | |
} | |
Object.setPrototypeOf(obj2, obj1); | |
// | |
//obj2.prop2(); | |
//obj2.prop1(); | |
//obj2.toString(); | |
//Object.getPrototypeOf(obj2).prop1(); | |
console.log(Object.getOwnPropertyNames(obj2) ) | |
console.log(Object.getOwnPropertyNames(obj1) ) | |
console.log(Object.getOwnPropertyNames( Object.getPrototypeOf(obj1) ) ) | |
for(let prop in obj2){ | |
console.log(prop); | |
} | |
//Object.create() | |
//Object.assign() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment