...

/

Introduction to Objects

Introduction to Objects

Learn the last data type we'll cover: objects. Objects are like arrays in that they group a set of information. They're more loose, however, and we interact with them differently. They're made up of key-value pairs.

Objects are another way to store a collection of values. While arrays keep everything ordered, objects provide a little more flexibility. They’re also a little harder to get the hang of.

Key-Value

An object is created with curly brackets {}. They’re made up of key-value pairs, also referred to as properties. Let’s start with an example.

Press + to interact
let obj = {
key: 'value'
};
console.log(obj); // -> { key: 'value' }

We’ve created an object with one item inside it, one key-value pair. The key is named ...