JavaScript Objects
Objects are used to store data in key-value pairs.
Creating an Object
You can create an object using curly braces {}:
let person = {
name: "John",
age: 30,
city: "New York"
};
Accessing Object Properties
You can access properties using dot notation or bracket notation:
console.log(person.name); // Output: John
console.log(person["age"]); // Output: 30
Adding or Modifying Properties
You can add or modify properties dynamically:
person.country = "USA";
person.age = 31;
console.log(person); // Updated object