A JavaScript reference points to a Value.
Simple values (that is, scalar primitive type values, basic type values, JS 6 classes, null, undefined, boolean, number, string, and Symbol) are always assigned/passed in the way value is Copied.
For example, at this point, the variable a holds a copy of the value, and variable B holds another copy of him, no matter what kind of action B takes, and no longer affects the value of A.
Composite values-objects (including Arrays and encapsulated objects) and functions are always assigned values/passes by reference to Replication.
As an example of an array, A and B point to two different references to the same composite value [three-to-one], pointing only to, not holding, so if one of a and B changes, they change the original array, and then they point to the new value after the change [1,2,3,4].
A different way of doing B:
At this point, the assignment to b, assigning another array to b,b is no longer a point of reference a, and there is no relation to the point value of a, so the operation of B no longer affects the value of a Point.
Function parameters are often confusing:
Only such operations, in general, can also be understood.
In this case, there will be confusion, using the assignment of the composite value as described earlier, without any effect on the value of the referenced target value [4,5,6], which does not have any effect on the value of the array referenced by a, so a remains [1,2,3,4].
At this point in the function body, there is no assignment class operation, The X operation has always been the reference value of the array, so after the push of the new value, it is the value of the reference is modified, a point is also the changed new value [4,5,6,7].
The operation of a JSON object is similar in principle to an array.
Simple scalar primitive type values (strings and numbers, etc.) are assigned values/passes by value copying, while composite values (objects, Etc.) are assigned values/passes by reference Assignments.
JavaScript values and references