JavaScript Objects & Manipulation — Beginner Friendly Guide

Himmat Kumar Jun 1, 2025, 1:17 AM
Blog Thumbnail

🧠 JavaScript Objects and their Manipulations

📦 Object Creation

An example of a user-related simple object is shown below.

const user = { name: "Alice", age: 25, email: "alice@example.com" };

🔍 Accessing Values of an Object’s Property

You can access values by the property name through the dot or the brackets notation.

console.log(user.name); // Alice

console.log(user["email"]); // alice@example.com

📝 Modifying An Object's Field

To make a change to the object, assign a different value to that key.

user.age = 26;

user["email"] = "alice.new@example.com";

➕ Property Addition

It is also possible to add properties dynamically.

user.country = "India";

❌ Object Property Removal

To remove a given property, employ the delete operator.

delete user.age;

🔁 Object Key Iteration

A for…in loop will iterate all keys.

for (let key in user) {

console.log(key + ": " + user[key]);

}

✅ TL;DR: Object Cheatsheet

  • To create: const obj = { key : value }
  • To access: obj.key or obj[“key”]
  • To update: obj.key = new Value
  • To add: obj.newKey = value
  • To delete: delete obj.key
  • To loop: for…in for iterating in the keys or values.
💡 Pro Tip: Managing data that is structured like users, their settings, or any other containing multi-values, would be easier with object-oriented programming.

Related Posts

Himmat Kumar Jun 1, 2025, 12:57 AM

Date and Time in JavaScript — Easy Guide

Himmat Kumar May 31, 2025, 7:47 PM

JavaScript Variables: var vs let vs const

Himmat Kumar May 31, 2025, 7:47 PM

JavaScript Data Types Explained with Examples

Himmat Kumar May 31, 2025, 7:47 PM

JavaScript Loops — for, while, do...while

Himmat Kumar May 31, 2025, 7:47 PM

JavaScript Functions & Scope

Himmat Kumar May 31, 2025, 7:47 PM

Introduction JavaScript

112 viewsLaravel
Himmat Kumar Jun 1, 2025, 12:53 AM

Master Laravel: Basic System Requirement,Installation a...