Numerical transfer of parameters in/js
This pass is equivalent to copying the value of Count to a num,num change does not affect the count (two different memory regions)
function addten(num) {
num + = ten;
return num;
}
var count = ;
var result = Addten (count);
Console.log (count); //20
Console.log (Result); //30
The transfer of parameters in JS
This pass is the value of person (the person here gets a pointer to an object address in memory, which is remembered as a pointer), so add the name to obj
property is to add the Name property to the corresponding memory area , and the result is that the person takes the name attribute to get
function setName(obj) {
console.log (obj);
obj.name = "Meinv";
}
var person = new Object ();
SetName (person);
Console.log (person.name); //MEINV
In fact, the essence of both methods are the same, are the corresponding values passed the past, the difference is the second pass is the memory address,
All parameters of the function are passed by value, that is, the values outside the function are copied to the parameters inside the function
JS pass-through parameters