Objects: Named Properties

Learn how to group related data together using objects — JavaScript's key-value data structure.

Step 1 of 5

Data with labels, not numbers

Arrays are great for ordered lists, but sometimes position numbers don't make sense. If you're storing information about a person — their name, age, and email — would you remember that index 0 is the name, index 1 is the age, and index 2 is the email? That's fragile and confusing.

Objects solve this by letting you label each piece of data with a descriptive name. Instead of positions (0, 1, 2), you use keys (name, age, email). Each key is paired with a value, forming a key-value pair. Together, the pairs describe a single thing — a person, a product, a song, a tweet.

Objects are everywhere in web development. API responses from servers, user profiles, configuration settings, and event data are all typically objects.

Think of it this way: An object is like a contact card — instead of numbered slots like arrays, each piece of data has a label: name, phone, email. You don't ask for 'the first field' — you ask for 'the phone number.' The labels make the data self-describing.
Web Standard
Nearly everything in JavaScript is an object or behaves like one. Arrays are objects. Functions are objects. Even strings have object-like behavior (which is why they have methods like `.toUpperCase()`). Understanding objects is understanding the core of JavaScript.
JAVASCRIPTREAD ONLY
CONSOLE
Click "Run" to execute your code...