JavaScript: 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
- Object Tutorial
- Object Overview
- Object Type
- Test If a Value is Object Type 🚀
- Find Object's Type
- Prototype and Inheritance
- Prototype Chain
- Is in Prototype Chain?
- Get/Set Parent
- Show Parent Chain 🚀
- Create Object
- Object Literal Expr
- Create Object + Parent
- Prevent Adding Property
- Clone Object 🚀
- Test Object Equality 🚀
- Add Method to Prototype