Search⌘ K

Data Structures: Objects

Explore how to define and work with JavaScript objects, including creating properties, accessing values using dot and bracket notation, and iterating over properties with loops. This lesson helps you understand objects as versatile data structures to store and organize information effectively.

Introduction to objects

A JavaScript object is another variable that allows us to store multiple pieces of data. Like arrays, objects are capable of storing any valid JavaScript data type, including arrays and other objects. However, unlike arrays, data in objects are stored in object properties.

Let’s once again take the example of a classroom with students. We will make a single student an object with multiple properties:

Node.js
var student = {
name: "Mary",
age: 10
}

An object is declared using curly braces ({}). Properties and their values are stored within the ...