Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/***********************************************************
// [ 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
You can’t perform that action at this time.