JS data is divided into basic types (number, string, Boolean, null, undefined) and reference types (Object, Array, Data, REGEXP, function, etc.) two. The value of the base type variable is itself, where a=3, the value of a is 3, and the value of the reference type's variable obj={b:1},obj itself is the address of the store {b:1}, and {b:1} is the content it points to.
When you pass a value, both of your own value (A is 3,obj is the address) copies a copy to the formal parameter, note that {b:1} is still only one, but at this point, there are two reference types of variables that point to it, you can modify the contents of {b:1} by any one, but if you modify the point of any reference variable (its own value) , the point of another reference variable does not change.
var obj={a:1,b:2}; Reference type
var v=0; Basic type
function test (arg,v) {
arg.a=2; The value of the outer obj.a can be overwritten because at this point arg and obj are pointing to the same
arg={}; The original obj is not equal to {}
arg.a=1; The value of OBJ.A cannot be overwritten because at this point arg points to the changed
v=100; The value of V can not be changed
}
Test (obj,v);
Console.log (obj); {a:2, b:2}
Console.log (v);//0