1function copy(arr1, arr2) {
2 for (var i =0; i< arr1.length; i++) {
3 arr2[i] = arr1[i];
4 }
5}
6copy(arr1, arr2)
1//recursive deep copy of object
2function dup(o) {
3 // "string", number, boolean
4 if(typeof(o) != "object") {
5 return o;
6 }
7
8 // null
9 if(!o) {
10 return o; // null
11 }
12
13 var r = (o instanceof Array) ? [] : {};
14 for(var i in o) {
15 if(o.hasOwnProperty(i)) {
16 r[i] = dup(o[i]);
17 }
18 }
19 return r;
20}
21