×

JavaScript Objects

Object Creation using Object.create() Method

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().

Intermediate 25 Minutes Monopoly IT Solutions Updated 2026-08-04
Java class training banner
5.0
5.0
4.6
Overview

What you'll cover

Learning objectives

  • Understand Object.create()
  • Understand Prototype Object
  • Create Objects using Prototype
  • Define Properties Dynamically
  • Use Object.defineProperty()
  • Use Object.defineProperties()
  • Access Prototype Properties

Prerequisites

  • Variables
  • Functions
  • JavaScript Objects
  • Object Literal
  • Prototype

Related topics

  • Object Literal
  • Object Constructor
  • Constructor Function
  • Prototype
  • Prototype Chain
  • Inheritance
Theory

Concept breakdown

Object.create()

The Object.create() method creates a new object using an existing object as its prototype.

Prototype Object

The prototype object acts as the parent object from which properties and methods are inherited.

Object.defineProperty()

Adds or modifies a single property of an object.

Object.defineProperties()

Adds or modifies multiple properties of an object simultaneously.

Syntax
Hands-on example

Object Creation using Object.create()

Console Output
> {
  "firstName": "Sathesh",
  "lastName": "Kumar",
  "age": 30
}
> [
  "firstName",
  "lastName",
  "age"
]
> "Monopoly IT Solutions"
Walkthrough

Step by step

  1. 1

    Create Prototype Object

    Create companyObj containing companyName and companyAddress.

  2. 2

    Create New Object

    Create empObj using Object.create(companyObj).

  3. 3

    Add Single Property

    Use Object.defineProperty() to create the firstName property.

  4. 4

    Add Multiple Properties

    Use Object.defineProperties() to create lastName and age.

  5. 5

    Display Object

    Display the employee object in the browser console.

  6. 6

    Retrieve Keys

    Use Object.keys() to retrieve the object's own enumerable property names.

  7. 7

    Access Prototype Property

    Access companyName inherited from the prototype object.

Summary

Key takeaways

Key points

  • Object.create() creates a new object using another object as its prototype.
  • Inherited properties are available through the prototype chain.
  • Object.defineProperty() defines a single property.
  • Object.defineProperties() defines multiple properties.
  • Object.keys() returns only the object's own enumerable properties.
  • Prototype properties are not returned by Object.keys().

Advantages

  • Supports Prototype-based inheritance.
  • Creates lightweight objects.
  • Easy to reuse existing objects.
  • Provides fine-grained property control.
  • Supports property descriptors.

Disadvantages

  • Prototype chain may confuse beginners.
  • Property descriptors require additional syntax.
  • Inherited properties are not returned by Object.keys().
Real-world use

Employee Management System

Company information can be stored in a prototype object, while every employee object inherits company details and stores only employee-specific information.

Interview prep

Frequently asked questions

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.

Test yourself

Quick MCQ practice

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?

Apply it

Practice on your own

Coding exercise

Student Prototype Object

Create a college object and create multiple student objects using Object.create(). Add properties using Object.defineProperties().

Assignment

  1. Create a Product prototype object.
  2. Create a Mobile object using Object.create().
  3. Add model, RAM and price using Object.defineProperties().
  4. Display inherited and own properties.
  5. Print all property names using Object.keys().

Tags

#javascript#object-create#prototype#object#inheritance#oop

getintouch

Book for Live Demo!