"JavaScript is always passed by reference" - this, as well as a [white] lie and confusion of terms. Although there is a “gray area”, I pass on to these definitions of evaluation strategies .
Here are my arguments and reasoning. If you hold a different view, make sure you can at least support it.
Call By Reference means (for many people) that parameter assignment affects bindings in the caller.
When evaluating a package (also called "forwarding"), the function receives an implicit reference to the variable used as an argument, and not to a copy of its value. This usually means that the function can change (i.e., Assign) the variable used as an argument - something that will be visible to its caller.
This does not apply to JavaScript, as the original message is noted in the observed behavior. Re-assigning a parameter (which can be thought of as a local variable with a dynamically supplied value) does not affect any arguments provided.
Sometimes “Call By Reference” is used [confusingly] to mean “Call By Sharing” or “Call By Value [of Reference],” as discussed below; true Call By Reference is in languages like C ++ and VB, but not JavaScript.
JavaScript calling conventions can be fully discussed in terms of Calling on [Object] Sharing semantics.
All JavaScript objects are values; and all primitive values (which are a subset of all values) are immutable.
The semantics of a call by sharing differs from a call by reference in that the assignments for the function arguments inside the function are not displayed to the caller, for example, if a variable has been passed, it is impossible to simulate the assignment of this variable in the call area. However, since the function has access to the same object as the caller (without copying), mutations for these objects, if the objects are mutable, are visible to the caller inside the function, which may differ from the semantics of the call by value.
An example of these Shared mutations is presented in the ultrayoshi answer and can be explained simply: when an expression (such as accessing a variable) is evaluated by the object and the specified object is passed to the function, a copy / clone is not created.
While the terminology "Call By Value [of Reference]" is often used to describe behavior, it should be noted that JavaScript has no links (or "non-core" values) in the sense of Java / C #, so this terminology is subtlely misleading - at least that doesn't say Call By Reference, with different connotations, and many people understand the low explanation.
In a call by value, an argument expression is calculated, and the resulting value is bound to the corresponding variable in the function. If a function or procedure can assign values to its parameters, then only its local copy is assigned — that is, [any variable] passed to the function call does not change in the call area when the function returns.
Since only a “link” to the object is transmitted (and not a copy / cloning of the specified object), semantics are simply a “sharing call”. However, I avoid this terminology in JavaScript, because then it leads to unnecessary implementation details, and also introduces a difference in how implementations convey objects against primitive values.
The description "call-by-value, where the value is a reference" is general (but should not be understood as a call by reference); Another term is call sharing.
So when I talk about convention calls in JavaScript,
I prefer to use Call By Sharing to discuss behavior, and I avoid Call By [Value / Reference] because they have too many different “values” and drag and drop unnecessary implementation details.