Updating a global array
Dear friends!
I do not remmber what I have done some days ago - global arrays are no more updated. I have cut it down to this mechanism:
var arrayOfObjects = []; // global Array
UpdateA (arrayOfObjects); // array is NOT updated
$.writeln ("1) arraOfObjects = \n" + arrayOfObjects);UpdateB (arrayOfObjects); // array is NOT updated either
$.writeln ("2) arraOfObjects = \n" + arrayOfObjects);function UpdateA (gArray, someotherStuff) {
var locObject = new Object();
locObject.Name = "A";
locObject.Item = "Something";gArray = [locObject, locObject, locObject];
$.writeln ("A) gArray = " + gArray);
}function UpdateB (gArray, someotherStuff) {
var locObject = new Object();
locObject.Name = "A";
locObject.Item = "Something";
var localArray = [locObject, locObject, locObject];
gArray = localArray.slice();
$.writeln ("B) gArray = " + gArray);
}
The output is quite clear: the gobal array is not touched at all by the Update functions:
A) gArray = [object Object],[object Object],[object Object]
1) arraOfObjects =B) gArray = [object Object],[object Object],[object Object]
2) arraOfObjects =
Have I become blind?
In the original script the update function collects markers and (did so) put them into the global array.
It seems that I need a tool to save changes ...
Klaus

