🪟 Windows TippsModify Windows Support Phone Number with PowerShell(03.09.2026 um 00:00 Uhr)
🔧 AI Nachrichten Podcast: ChatGPT schwatzt Nutzern in Deutschland jetzt Werbung auf(28.08.2026 um 08:46 Uhr)
🪟 Windows TippsMicrosoft bringt Emoji 17.0 auf Windows 11(31.08.2026 um 08:16 Uhr)
🪟 Windows TippsModify Windows Support Phone Number with PowerShell(03.09.2026 um 00:00 Uhr)
🔧 AI Nachrichten Podcast: ChatGPT schwatzt Nutzern in Deutschland jetzt Werbung auf(28.08.2026 um 08:46 Uhr)
🪟 Windows TippsMicrosoft bringt Emoji 17.0 auf Windows 11(31.08.2026 um 08:16 Uhr)

🔧 Programmierung 🕛 vor 2 Monaten 5 Min Lesezeit
0

Objects in JavaScript

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Objects are one of the most important concepts in JavaScript. Almost everything in JavaScript revolves around objects.



Objects help us store related data together and represent real-world entities such as:




  • Students

  • Employees

  • Cars

  • Mobiles

  • Products

  • Users

  • Animals









What is an Object?



An object is a collection of properties and methods.





  • Properties store data.


  • Methods store functions.






Syntax






CODE
const objectName = {
key1: value1,
key2: value2
};












Example






CODE
const student = {
name: "John",
age: 21,
city: "Chennai"
};

console.log(student);






Output:




CODE
{
name: "John",
age: 21,
city: "Chennai"
}












Real-Life Example



Think of a Student ID Card.




CODE
Name : John
Age : 21
City : Chennai






All these details belong to one student.



Similarly:




CODE
const student = {
name: "John",
age: 21,
city: "Chennai"
};






The object stores related information together.









Why Do We Need Objects?



Without Objects




CODE
let name = "John";
let age = 21;
let city = "Chennai";






Managing multiple variables becomes difficult.



With Objects




CODE
const student = {
name: "John",
age: 21,
city: "Chennai"
};






Everything is organized inside one object.









Object Terminologies



Consider:




CODE
const laptop = {
brand: "HP",
ram: "16GB",
price: 70000
};






Here,




































Term Value
brand Property
ram Property
price Property
"HP" Value
"16GB" Value
70000 Value








Creating Objects



There are several ways to create objects.









1. Object Literal



Most commonly used.




CODE
const mobile = {
brand: "Samsung",
model: "S25",
price: 90000
};

console.log(mobile);






Output




CODE
{
brand: "Samsung",
model: "S25",
price: 90000
}












Real-Life Example



Writing details in a notebook.




CODE
Brand : Samsung
Model : S25
Price : 90000












Accessing Object Properties



There are two ways:






Dot Notation






CODE
const mobile = {
brand: "Apple",
model: "iPhone 16"
};

console.log(mobile.brand);






Output




CODE
Apple












Bracket Notation






CODE
console.log(mobile["model"]);






Output




CODE
iPhone 16












Real-Life Example



Finding a contact in your phone.




CODE
Contact Name → Mobile Number






Similarly,




CODE
mobile.brand






retrieves the value.









Adding Properties



Objects are dynamic.




CODE
const laptop = {
brand: "Dell"
};

laptop.ram = "16GB";

console.log(laptop);






Output




CODE
{
brand: "Dell",
ram: "16GB"
}












Real-Life Example



Buying a laptop and later upgrading RAM.



Initially:




CODE
Brand : Dell






Later:




CODE
Brand : Dell
RAM : 16GB












Updating Properties






CODE
const laptop = {
brand: "Dell",
ram: "8GB"
};

laptop.ram = "16GB";

console.log(laptop);






Output




CODE
{
brand: "Dell",
ram: "16GB"
}












Real-Life Example



Changing your phone number in a bank account.



Old




CODE
9876543210






New




CODE
9999999999












Deleting Properties






CODE
const laptop = {
brand: "HP",
camera: "1080p"
};

delete laptop.camera;

console.log(laptop);






Output




CODE
{
brand: "HP"
}












Real-Life Example



Removing old information from a form.









CRUD Operations with Objects



CRUD means:




  • Create

  • Read

  • Update

  • Delete




CODE
const laptop = {
brand: "Lenovo",
ram: "8GB"
};

// Create
laptop.processor = "i7";

// Read
console.log(laptop.ram);

// Update
laptop.ram = "16GB";

// Delete
delete laptop.processor;

console.log(laptop);






Output




CODE
{
brand: "Lenovo",
ram: "16GB"
}












Objects with Methods



Methods are functions inside objects.




CODE
const student = {

name: "John",

greet: function() {
console.log("Hello");
}

};

student.greet();






Output




CODE
Hello












Real-Life Example



A Car



Properties




CODE
Brand
Color
Price






Actions




CODE
Start()
Stop()
Accelerate()






Actions are methods.









Using this Keyword






CODE
const student = {

name: "John",

greet: function() {
console.log("Hello " + this.name);
}

};

student.greet();






Output




CODE
Hello John












Real-Life Example



Suppose a teacher says:




"My class"




Here "my" refers to the teacher.



Similarly,




CODE
this.name






refers to the current object.









Nested Objects



Objects can contain other objects.




CODE
const employee = {

name: "David",

address: {
city: "Chennai",
state: "Tamil Nadu"
}

};

console.log(employee.address.city);






Output




CODE
Chennai












Real-Life Example



Company




CODE
Company

Department

Employee






Similarly




CODE
Object

Nested Object












Object.keys()



Returns all keys.




CODE
const student = {
name: "John",
age: 22
};

console.log(Object.keys(student));






Output




CODE
["name","age"]












Object.values()



Returns values.




CODE
console.log(Object.values(student));






Output




CODE
["John",22]












Object.entries()



Returns key-value pairs.




CODE
console.log(Object.entries(student));






Output




CODE
[
["name","John"],
["age",22]
]












Looping Through Objects



Using for...in




CODE
const student = {

name: "John",
age: 21,
city: "Chennai"

};

for(let key in student){
console.log(key, student[key]);
}






Output




CODE
name John
age 21
city Chennai












Real-Life Example



Checking items in a grocery bill one by one.









Object Destructuring



Extract values easily.




CODE
const laptop = {
brand: "HP",
ram: "16GB"
};

const {brand, ram} = laptop;

console.log(brand);
console.log(ram);






Output




CODE
HP
16GB












Real-Life Example



Removing specific books from a shelf instead of carrying the entire shelf.









Spread Operator with Objects






CODE
const student = {
name: "John",
age: 20
};

const details = {
...student,
city: "Madurai"
};

console.log(details);






Output




CODE
{
name:"John",
age:20,
city:"Madurai"
}












Object.freeze()



Prevents modification.




CODE
const car = {
brand: "BMW"
};

Object.freeze(car);

car.brand = "Audi";

console.log(car);






Output




CODE
{
brand:"BMW"
}












Real-Life Example



Submitting an exam paper.



After submission, changes cannot be made.









Object.seal()



Allows updating but prevents adding or deleting properties.




CODE
const car = {
brand: "BMW"
};

Object.seal(car);

car.brand = "Audi";

console.log(car);






Output




CODE
{
brand:"Audi"
}












Object Constructor






CODE
const person = new Object();

person.name = "John";
person.age = 22;

console.log(person);






Output




CODE
{
name:"John",
age:22
}












Factory Function






CODE
function createStudent(name, age){

return {
name,
age
};

}

let s1 = createStudent("John",21);

console.log(s1);






Output




CODE
{
name:"John",
age:21
}












Constructor Function






CODE
function Student(name, age){

this.name = name;
this.age = age;

}

const s1 = new Student("John",21);

console.log(s1);






Output




CODE
{
name:"John",
age:21
}












Objects vs Arrays




























Objects Arrays
Store data in key-value pairs Store values by index
Uses property names Uses index numbers
Represents entities Represents collections
Accessed using keys Accessed using indexes





Example



Object




CODE
const student = {
name:"John",
age:21
};






Array




CODE
const marks = [90,85,95];












Real-World Examples of Objects






Student






CODE
const student = {
name: "John",
age: 20,
department: "CSE"
};












Car






CODE
const car = {
brand: "BMW",
color: "Black",
price: 6000000
};












Employee






CODE
const employee = {
id: 101,
name: "David",
salary: 50000
};












Product






CODE
const product = {
name: "Laptop",
price: 70000,
stock: 20
};









References :

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Modify Windows Support Phone Number with PowerShell
1 Quelle
Die Zukunft des Einkaufens: Warum wir ein neues Kapitel aufschlagen (und wie du es mitschreiben kannst)
1 Quelle
ZDE Podcast 251: Wie sieht digitales Instore Marketing 2026 aus, Amit Chatterjee?
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Objects in JavaScript

Thematisch verwandte Begriffe: Objects, JavaScript · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...