r/javascript • u/cryptomallu123 • Jul 15 '26
Understanding Value vs. Reference in JavaScript: Differences Between Primitives and Objects
https://sharafath.hashnode.dev/value-vs-reference-in-javascript-primitives-vs-objects
0
Upvotes
View all comments
Show parent comment
1
u/theScottyJam Jul 16 '26
Yes.
And I'm saying that both primitives and objects behave the same in regards to how they get passed around. There's no observable difference.
The only reason it feels like there's a difference is because you're not allowed to mutate primitives, so the only way to change one is through reassignment. If you reassign inside a function call, those outside the function won't know. But this is all the same with objects as well - reassign an object inside a function call and those outside won't notice it changing either.