The Object.create() method creates a new object using an existing object as its prototype. It enables prototype-based inheritance and allows properties to be defined while creating the object or later using Object.defineProperty() and Object.defineProperties().
The Object.create() method creates a new object using an existing object as its prototype.
The prototype object acts as the parent object from which properties and methods are inherited.
Adds or modifies a single property of an object.
Adds or modifies multiple properties of an object simultaneously.
> { "firstName": "Sathesh", "lastName": "Kumar", "age": 30 }> [ "firstName", "lastName", "age" ]> "Monopoly IT Solutions"
Create companyObj containing companyName and companyAddress.
Create empObj using Object.create(companyObj).
Use Object.defineProperty() to create the firstName property.
Use Object.defineProperties() to create lastName and age.
Display the employee object in the browser console.
Use Object.keys() to retrieve the object's own enumerable property names.
Access companyName inherited from the prototype object.
Company information can be stored in a prototype object, while every employee object inherits company details and stores only employee-specific information.
It creates a new object using another object as its prototype.
A prototype is the parent object from which another object inherits properties and methods.
Object.defineProperty() defines one property, whereas Object.defineProperties() defines multiple properties.
No. It returns only the object's own enumerable properties.
Yes. If the property is not found in the object, JavaScript searches the prototype chain.
1. Which method creates an object using another object as its prototype?
2. Which method defines multiple properties?
3. Which method returns only enumerable property names?
Create a college object and create multiple student objects using Object.create(). Add properties using Object.defineProperties().
