Solice UI
Back to the curriculum

Chapter 4 · JavaScript & the DOM

Arrays and objects

Most page data is not one isolated value. Arrays represent ordered collections, while objects group named facts about one thing, such as a lesson, user preference, or search result.

Beginner · Lesson 4 of 6 in this chapter

Arrays preserve an order

Array items are accessed by position and can be mapped into visible rows, filtered by a condition, or searched for one match. Avoid changing an array in surprising places when other code expects the original order.

Objects describe one record

Object properties use names such as title, path, and summary. This makes a record self-describing and easier to extend than an array whose positions carry hidden meanings.

Representing a curriculum

  1. An array keeps chapters in their teaching order.
  2. Each chapter object stores its title and description.
  3. A nested lesson array stores the six related lesson objects.
  • Use arrays for collections and objects for named records.
  • Methods such as map and filter express common list work.
  • Preserve one clear owner for shared data.