DEV Community

loading...

Discussion on: Understanding the Difference Between Reference and Value in JavaScript

Collapse
thawkin3 profile image
Tyler Hawkins Author

Valentin, thank you for the correction and the detailed articles!

The mental model I've had that "primitives are passed by value; objects are passed by reference" has served me well over the years, and it's been helpful in understanding what behavior to expect, but it appears that I've been using the incorrect terms to explain what's really going on underneath the hood.

I've read through all your linked references. Just for my understanding, it seems like the following statement from the Stack Overflow answer is an appropriate way to explain the concept, right?

Primitives are passed by value. Objects are passed by "copy of a reference".

Or as you've said:

It is always pass by value. The "value" of an object is the reference.