Skip to main content
Module 3 · Lesson 1 of 49/32 in the course~16 min
Module lessons (1/4)

Arrays: the ordered list

Lesson preview5 hands-on exercises readyJavaScript Course · Module 3 — Arrays and objects

Creating an array, read/write by index, push/pop/shift/unshift, length.

What you'll learn in this lesson

  • Create, read, and index sorted arrays (arr[0], arr[arr.length - 1], .at(-1)).
  • Distinguish mutant operations (push, pop, shift, unshift) from immutable alternatives ([...arr, x], .slice).
  • Understand why two arrays compare by reference ([1] === [1] is false).
  • Search for elements with .includes() and .indexOf() and produce new arrays without changing the input.

Overview

An array is a sorted list indexed from zero. Unlike numbers and strings, arrays are objects stored in the Heap by reference - understanding when you are mutating the existing array vs creating a new array prevents silent status bugs.

Sections covered in this lesson

  1. 1Mental model: mutation in place vs immutable copy
  2. 2Progressive examples
  3. 3Guided laboratory
  4. 4Check for understanding
Pro Lesson · Module 3 — Arrays and objects

Unlock "Arrays: the ordered list" and the full JavaScript Course curriculum

Creating an array, read/write by index, push/pop/shift/unshift, length.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in JavaScript Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.