I have a result set, which is an array of objects. I need to clone this so that I can make changes to it without touching the source data.
var data = w2ui.grid.records, exclude = Array('recid', 'w2ui'); // Exclude these data points from the pivot // Modify our tempData records to remove HTML $.each(data, function(key, value) { $.each(value, function(_key, _value) { if(jQuery.inArray(_key, exclude) != -1) { delete data[key][_key]; }else{ data[key][_key] = $('<div>'+_value+'</div>').text(); // <div></div> for those which are simply strings. } }); });
In this example, I created a variable called data
and set it to "Source Data".
I expected that I could make changes to this new data variable, but it seems that when I make changes to it, the original data changes ( w2ui.grid.records
).
Is there a way to clone this set so that I can change a new data instance?
source share