Back to Lessons

Arrays and Objects

Work with arrays and objects, including methods and properties

Overview

Arrays store multiple values in a single variable. Objects store key-value pairs.

Arrays: const arr = [1, 2, 3, 4, 5]; arr.push(6); arr.map(x => x * 2);

Objects: const person = { name: "John", age: 30 }; person.name; person["age"];

Both are essential data structures in JavaScript. Arrays are great for ordered collections, while objects are perfect for structured data with named properties.

Code Example

Loading...