This afternoon, thinking about calling the function, what about the arguments passed to the executing function. When the type of the value is different, there is no change.
When the value of the parameter is the basic type, this time is passed by value, this is definitely clear, but the time is the reference type, this time what is the situation ah.
When we pass an object as an argument, we find out how to run the Funx function, but the global object A variable is also modified, which is a bit confusing. When a parameter is passed, it is not passed by value, why is the property of the object in the external environment modified. It seems that this is a reference pass. However, if we run a function like the following:
found that the output of the results did not become 20, in fact, when the function parameters become reference types, we have changed the value, we know that the basic data type JS is stored in the stack memory, and the reference type is stored in the heap memory. When we point to this reference type with a variable, the variable is not determined to point to the reference type, but rather a pointer to the memory in which the reference type resides. When we pass a reference type in a function, it's actually the same thing, we just pass the pointer in.
Thinking on the reference of JavaScript function