When you pass a primitive value it is copied into the…
““When you pass a primitive value it is copied into the parameter. We call this “passing by value.” So if you change the value of the parameter in your function body it has no affect on our original argument’s value. The exception to this is passing an array or object, and we’ll get to that in a bit.””
About This Quote
This interpretation was drafted with AI assistance. It is one reading of the quote, not the author's own explanation.
Passing primitive values copies them, so changes inside a function don't affect the original variable; objects and arrays are passed by reference.
In simple terms: Primitives are copied, objects are referenced.
Know when your data is mutable.
Themes
Mood
Type
When to use this quote
- debugging
- API design
- performance tuning
Key Concepts
Questions to Reflect On
- Do you need a copy or a reference?
- How can unintended mutations be avoided?
Changing an object inside a function can cause side effects elsewhere.