Consider this chunk of code, which is a basic example of passing an argument by value (here it's an object, which is passed by value):
function setName(obj) {
obj.name = "Pork";
obj = new Object();
obj.name = "Chicken";
}
var person = new Object();
setName(person);
alert(person.name);
The output of this code is "Pork" (obviously), but what I'm trying to understand is why the new object created in the setName function does not overwrite the value stored in obj. Instead, this apparently creates a pointer to a local object, which is destroyed when the function execution ends.