I have a default nested array called default_array, very simple :
default_array = [
["a", "b", "c"]
];
And I create a obj called obj where the value of his array attribute is the copy of default_array :
obj = {
"array" : default_array.slice(0)
};
But when I modify a element of the obj.array like this :
obj.array[0][0] = "z";
This modify also the default_array. I want this modification doesn't affect default_array. I want to preserve default_array.
Any idea ?
var copy = default_array.map(function(e) { return e; });Then usecopy