(asking for advice) on the problem of js function passing by value

after reading the book of higher education, the chapter on function transfer, there is such a code:

    function setName(obj) {
        obj.name = ""
        obj = new Object()
        obj.name = ""
    }
    var person = new Object()
    setName(person)
    console.log(person.name)
The

book says that function parameters are passed by value. When obj is rewritten inside the function, this variable refers to a local variable, but I wrote one myself:

    var obj1 = new Object()
    var obj2 = obj1
    obj1.name = ""
    obj1 = new Object()
    obj1.name = ""
    obj2.age = 22
    console.log(obj1.age) //undefined
    console.log(obj2.name) //

after rewriting obj1, change the value of obj1, and the value of obj2 does not change. On the contrary, after changing the value of obj2, it will not change either. Isn"t this the same as passing parameters to the function? they are all passed by value

.
Aug.19,2021

1. Basic type data (boolean, null, undefined, string and number) is passed by value
2 as function parameters, and other types of data (object, array and function) as function parameters are passed by share, passing copies of references (which can also be understood as passing by value)

// :
var person = new Object() //person  a{}
setName(person) // a
function setName(obj) { // obja
    obj.name = '' // a{name: ''}
    obj = new Object() // obj b{}
    obj.name = '' // b{name: ''}
}
console.log(person.name) // a{name: ''}
The

function does not pass parameters by value
in js just remember that basic types are passed by value, and reference types are passed by reference

Menu