Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created January 25, 2018 03:36
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/e48b5c43a91a8a52b724f92fc8f314b5 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/e48b5c43a91a8a52b724f92fc8f314b5 to your computer and use it in GitHub Desktop.
/***********************************************************
// [ 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