JS: Get Set Prototype
Get Parent
You can use the following to get a object's parent:
- Reflect.getPrototypeOf → best way.
- Object.getPrototypeOf → implicitly convert arg to object type if not already.
- Object.prototype.__proto__ → hack. Not always work.
Set Parent
- Reflect.setPrototypeOf → best way.
- Object.setPrototypeOf → implicitly convert arg to object type if not already.
- Object.prototype.__proto__ → hack. Not always work.
🛑 WARNING: when object's parent change, all the object's children properties also change, due to Prototype and Inheritance .
JavaScript, Get Set Prototype
JavaScript, Object and Inheritance
- JS: Object Tutorial
- JS: Object Overview
- JS: Object Type
- JS: Test is Object Type 🚀
- JS: Determine Type of Object
- JS: Prototype and Inheritance
- JS: Prototype Chain
- JS: Object.prototype.isPrototypeOf
- JS: Get Set Prototype
- JS: Show Prototype Chain 🚀
- JS: Create Object
- JS: Object Literal Expression
- JS: Create Object with Parent X
- JS: Prevent Adding Property
- JS: Deep Copy Object, Array 🚀
- JS: Test Object Equality 🚀
- JS: Add Method to Prototype
- JS: Object Object
- JS: Object Constructor
- JS: Object.prototype