Tuesday, August 11, 2026
Home Academic Exploring JavaScript Object Methods- A Complete Guide for beginners

Exploring JavaScript Object Methods- A Complete Guide for beginners

Welcome back, JavaScript enthusiasts, to the JavaScript Learning series! In our previous discussion, we dove into the world of Loops in JavaScript, unraveling their power and versatility. Today, let’s continue our journey by exploring a set of essential JavaScript Object Methods that will enrich your understanding and elevate your coding skills.

1. Object.create():

The Object.create() method is a powerful tool for creating new objects with a specified prototype. This allows you to inherit properties and methods from an existing object.

Syntax:

javascriptCopy codeObject.create(prototype, [propertiesObject]);

Example:

// Creating a person object as a prototype
let person = {
  greet: function() {
    console.log(`Hello, ${this.name}!`);
  }
};

// Creating a new object using person as the prototype
let pamfa = Object.create(person);
pamfa.name = "Pamfa Ghimire";
pamfa.greet(); // Output: Hello, Pamfa Ghimire!

2. Object.keys():

The Object.keys() method returns an array of a given object’s property names.

Syntax:

Object.keys(object);

Example:

let scooty = {
  brand: "Honda",
  model: "Duo",
  year: 2018
};

let keys = Object.keys(scooty);
console.log(keys); // Output: ['brand', 'model', 'year']

3. Object.values():

Object.values() returns an array containing the values of the object’s own enumerable properties.

Syntax:

Object.values(object);

Example:

let scooty = {
  brand: "Honda",
  model: "Duo",
  year: 2018
};

let values = Object.values(scooty);
console.log(values); // Output: ['Honda', 'Duo', 2018]

4. Object.entries():

Object.entries() returns an array of a given object’s own enumerable property [key, value] pairs.

Syntax:

Object.entries(object);

Example:

let scooty = {
  brand: "Honda",
  model: "Duo",
  year: 2018
};

let entries = Object.entries(scooty);
console.log(entries); 
// Output: [['brand', 'Honda'], ['model', 'Duo'], ['year', 2018]]

5. Object.assign():

Object.assign() is used for copying the values of all enumerable properties from one or more source objects to a target object.

Syntax:

Object.assign(target, ...sources);

Example:

let scooty = {
  brand: "Honda",
  model: "Duo"
};

let additionalInfo = {
  year: 2018,
  color: "Black"
};

let completeScooty = Object.assign({}, car, additionalInfo);
console.log(completeScooty);
// Output: { brand: 'Honda', model: 'Duo', year: 2018, color: 'Black' }

6. Object.freeze():

The Object.freeze() method freezes an object, preventing new properties from being added, and existing properties from being removed or modified.

Syntax:

Object.freeze(object);

Example:

let person = {
  name: "Pamfa",
  age: 26
};

Object.freeze(person);
person.age = 31; // This assignment has no effect
console.log(person); // Output: { name: 'Pamfa', age: 26 }

7. Object.is():

Object.is() compares two values for equality. It returns true if the values are the same, and false otherwise.

Syntax:

Object.is(value1, value2);

Example:

console.log(Object.is(5, 5)); // Output: true
console.log(Object.is(0, -0)); // Output: false

8. Object.defineProperty():

The Object.defineProperty() method defines a new property directly on an object, or modifies an existing property on an object, and returns the object.

Syntax:

Object.defineProperty(object, prop, descriptor);

Example:

let person = {};

Object.defineProperty(person, 'name', {
  value: 'Pamfa',
  writable: false
});

person.name = 'Champa'; // This assignment has no effect
console.log(person.name); // Output: Pamfa

9. hasOwnProperty():

The hasOwnProperty() method returns a boolean indicating whether an object has the specified property as its own property, as opposed to inheriting it.

Syntax:

object.hasOwnProperty(prop);

Example:

let scooty = {
  brand: "Honda",
  model: "Duo"
};

console.log(scooty.hasOwnProperty('brand')); // Output: true
console.log(scooty.hasOwnProperty('color')); // Output: false

These JavaScript Object Methods are powerful tools that can significantly enhance your coding capabilities. By understanding and mastering these methods, you’ll be better equipped to manipulate and manage objects in your JavaScript applications. Stay tuned for more insightful content on datasagar.com, where we continue to unravel the mysteries of JavaScript in our ongoing learning series. Happy coding!

datasagarhttp://www.DataSagar.com
Sagar is multidisciplinary technologist, educator, and entrepreneur based in Nepal. As the founder of Illionso Technologies and Kashi Garden Resort, he operates at the intersection of web architecture, data intelligence, innovation, and digital transformation. From building digital solutions to scaling real-world concepts, his mission is to share knowledge alongside merge emerging as well as disruptive technologies with transformative offline experiences.
RELATED ARTICLES

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

What is Answer Engine Optimization (AEO)? Getting Ready for AI Powered Search and Agentic Era Digital Marketing

Search is changing faster than it has in the last two decades. For years, businesses focused on ranking their websites on search...

Most Popular

Why Linux Won the Infrastructure War? Lessons from Linus Torvalds

In 1991, 21-year-old Linus Torvalds announced a "hobby" operating system. Today, Linux powers supercomputers, cloud servers, and Android. Explore his journey, the open-source economy, and the lessons for modern developers.

What Is Vibe Coding? A Complete Beginner’s Guide to Building Software and Web Pages With AI

A few years ago, building a website meant sitting down with a programming book, picking a language, and slowly working through syntax...

What is Answer Engine Optimization (AEO)? Getting Ready for AI Powered Search and Agentic Era Digital Marketing

Search is changing faster than it has in the last two decades. For years, businesses focused on ranking their websites on search...

The Plain Text Web: Why llms.txt Is Becoming the New Site Standard

The web built today is heavy. Between client-side JavaScript, cookie banners, tracker scripts, and responsive CSS grids, a typical webpage carries megabytes...