Introduction
Objects help us group related information together in one place. They make it easier to organize and use data that belongs to the same thing.
Objects help us group related information together in one place. They make it easier to organize and use data that belongs to the same thing.
const objectName = {
key1: value1,
key2: value2,
key3: value3
};Keys are names that describe the data.
Values can be numbers, strings, arrays, or even other objects.
const person = { name: "Alice", age: 30 };
const product = { name: "Book", price: 9.99, inStock: true };
This program creates an object to store car details and then prints each detail.
const car = { brand: "Toyota", model: "Corolla", year: 2020 }; console.log(`Car brand: ${car.brand}`); console.log(`Model: ${car.model}`); console.log(`Year: ${car.year}`);
Objects help keep related data together, making code easier to read and manage.
You can change object values anytime by assigning new values to keys.
Objects group related data under one name.
They make it easy to organize and access information.
Objects are useful for representing real-world things in code.
const person = { name: 'Alice', age: 25 };const car = { brand: 'Toyota', year: 2020 };
console.log(car.brand);const book = { title: 'JS Guide', pages = 300 };Pass the test and this pattern moves unknown