This is my original array:
var myArray = [ {"A":"1", "B":"2"}, {"C":"3", "D":"4"}, {"E":"5", "F":"6"} ]
Then I create a copy of this myArray:
var copyArray = $.merge([], myArray);
And now I just want to expand the first copyArray element:
$.extend(copyArray[0], { "Hello": "World" });
But as a result, both myArray and copyArray change. I just want copyArray to be changed. They are both modified below:
[ {"A":"1", "B":"2", "Hello":"World"}, {"C":"3", "D":"4"}, {"E":"5", "F":"6"} ]
Here is my fiddle to show this: http://jsfiddle.net/LesignButure/GFVUy/
source share