I have this code
var myObjects = {}; //global variable
//Later on in the code:
for (i in myObjects)
{
var obj = myObjects[i];
process(obj);
}
function process(obj)
{
$.getJSON("example.com/process/", {id: obj.id}, function(result)
{
//Will the following change the permanent/global copy e.g
// myObjects[44] ?
obj.addItem(result.id, result.name, result.number);
}
);
}
Will the following line:
obj.addItem(result.id, result.name, result.number);
modify the object by value or by reference, i.e will it modify the local copy of obj
or e.g myObjects[44]
?
If it affects only the local copy, how can I have it change the global copy of the object?