Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
Think of Object.create() as a blueprint machine! You give it a prototype (the blueprint), and it creates a new object that inherits all the properties and methods from that blueprint. It's like saying "make me an object that acts like this parent object."
{} or new Object(), you have complete control over what the new object inherits. Perfect for implementing prototypal inheritance manually!The first argument becomes the new object's prototype - it inherits from this!
Second argument (optional) adds own properties to the new object with descriptors.
The new object can access all prototype properties via the prototype chain!
Unlike object literals, you choose exactly what the object inherits from!
Object.create(proto)Object.create(proto, propertiesObject)Use a parent object as blueprint for child objects
Add own properties during creation with descriptors
Pass null to create objects with NO prototype - perfect for dictionaries and hash maps without inherited properties!
const pureObject = Object.create(null);pureObject.name = 'Test';// No toString, hasOwnProperty, etc!Choose exactly what your object inherits from
New object inherits all properties from prototype
Add properties with descriptors during creation
Create pure objects with no inherited properties