Course contentsShow
← JavaScript
Lesson 50 of 2,7232. Values and TypesFree lesson

Arrays Are Objects Too

Learn that arrays are also reference types, with the same reference semantics as plain objects.

Arrays Are Objects Too

What you'll learn: You'll discover that arrays in JavaScript are actually a special type of object, which means they follow the same reference semantics you've learned about with plain objects.

Arrays Are Just Special Objects

In JavaScript, arrays aren't a separate, primitive data type—they're objects with a special syntax and some built-in behavior. Just like the objects you've already learned about, arrays are reference types.

This means everything you've learned about object references applies equally to arrays:

  • When you assign an array to a variable, you're storing a reference to that array in memory, not the array itself
  • When you copy an array variable, you're copying the reference, not creating a new array
  • Multiple variables can point to the same array in memory
  • Mutating an array through one reference affects all other references to that array

Why This Matters

Think of arrays like objects wearing a different outfit. Under the hood, they're the same kind of thing. An array is essentially an object where the keys happen to be numeric indices (0, 1, 2, etc.) and there's some extra functionality for managing the length property.

Because arrays are objects, they behave exactly like objects when it comes to references. If you pass an array to a function, that function receives a reference to the original array—not a copy. Changes made inside the function will affect the original array, just like with plain objects.

Key Takeaway: Arrays are reference types that behave exactly like objects—they're stored as references in memory, copied by reference, and can be mutated through any variable that points to them.