Objects
Named values.
An array is great for a list. But how do you store one thing with many details, like a person's name, age, and city? With an array, you'd have to remember which position is which. An object gives every value a name.

- One thing, many details
- Positions are hard to remember
- Objects name every value
Keys and values
Curly braces make an object. Inside, each entry is a key, a colon, and a value, separated by commas. The keys are the names, and the values can be anything, even arrays. Node prints the whole object neatly. Run it.
const person = {
name: "Ana",
age: 29,
city: "Lisbon",
hobbies: ["chess", "running"],
};
console.log(person);
console.log(person.name, "lives in", person.city);{
name: 'Ana',
age: 29,
city: 'Lisbon',
hobbies: [ 'chess', 'running' ]
}
Ana lives in LisbonObjects everywhere
Objects are the main way JavaScript organizes data. A user, a product, a setting, a message from a server, all objects. Arrays themselves are a special kind of object. And when we get to the browser, every element on the page is an object too.
| key | value |
|---|---|
| { key: value } | an object |
| Keys | names, usually camelCase |
| Values | any type |
| Everywhere | users, products, data |
Summary
Objects store values under names, called keys. They're the main way to organize data in JavaScript. Next, reading and changing properties.
Key takeaways- { name: 'Ana' }
- Key: value pairs
- Values can be anything