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.
A familiar example
Representing a curriculum
- An array keeps chapters in their teaching order.
- Each chapter object stores its title and description.
- A nested lesson array stores the six related lesson objects.
What to remember
- 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.