| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 | | export function klona(val) { |  |     var k, out, tmp; |  |   |  |     if (Array.isArray(val)) { |  |         out = Array(k=val.length); |  |         while (k--) out[k] = (tmp=val[k]) && typeof tmp === 'object' ? klona(tmp) : tmp; |  |         return out; |  |     } |  |   |  |     if (Object.prototype.toString.call(val) === '[object Object]') { |  |         out = {}; // null |  |         for (k in val) { |  |             if (k === '__proto__') { |  |                 Object.defineProperty(out, k, { |  |                     value: klona(val[k]), |  |                     configurable: true, |  |                     enumerable: true, |  |                     writable: true, |  |                 }); |  |             } else { |  |                 out[k] = (tmp=val[k]) && typeof tmp === 'object' ? klona(tmp) : tmp; |  |             } |  |         } |  |         return out; |  |     } |  |   |  |     return val; |  | } | 
 |