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 eg // myObjects[44] ? obj.addItem(result.id, result.name, result.number); } ); }
Will the following line:
obj.addItem(result.id, result.name, result.number);
change the object by value or by reference, that is, it will change the local copy of obj or, for example, myObjects[44] ?
If this affects only the local copy, how can I change the global copy of the object?
source share