Member-only story

What’s the Difference Between Primitive Values and Object References in JavaScript?

A critical distinction between immutable and mutable data

Chris Geelhoed
Better Programming
8 min readJan 16, 2020

--

Photo by Christopher Gower on Unsplash

All data types in JavaScript can be put into one of two categories: primitive values and object references.

Primitive values and object references behave differently. This difference in behavior affects how variable assignments are made, how equality operators get their results, and how JavaScript programs run in general.

Understanding the difference between primitive values and object references is critical to mastering JavaScript as a programming language. This piece will explain and illustrate this distinction in depth.

The following details will be covered:

  • What JavaScript data types fall into each category.
  • The difference between a value and a reference.
  • The difference between immutable and mutable data.
  • Practical examples comparing how primitive values and object references work.

Classifying JavaScript’s Eight Data Types

JavaScript currently supports eight different data types. This includes seven primitive value types and objects. Here’s the full…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

--

--

Responses (2)

What are your thoughts?