You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hoek provides several helpful methods for objects and arrays.
38
38
39
-
### clone(obj)
39
+
### clone(obj, [options])
40
40
41
-
This method is used to clone an object or an array. A *deep copy* is made (duplicates everything, including values that are objects, as well as non-enumerable properties).
41
+
Clones an object or an array. A *deep copy* is made (duplicates everything, including values that are
42
+
objects, as well as non-enumerable properties) where:
43
+
-`obj` - the object to be cloned.
44
+
-`options` - optional settings:
45
+
-`symbols` - clone symbol properties. Defaults to `false`.
42
46
43
47
```javascript
44
48
@@ -62,10 +66,13 @@ console.log(nestedObj.x.b); // results in 123456
62
66
console.log(copy.x.b); // results in 100
63
67
```
64
68
65
-
### cloneWithShallow(obj, keys)
66
-
keys is an array of key names to shallow copy
69
+
### cloneWithShallow(obj, keys, [options])
67
70
68
-
This method is also used to clone an object or array, however any keys listed in the `keys` array are shallow copied while those not listed are deep copied.
71
+
Clones an object or array excluding some keys which are shallow copied where:
72
+
-`obj` - the object to be cloned.
73
+
-`keys` - an array of key names to shallow copy.
74
+
-`options` - optional settings:
75
+
-`symbols` - clone symbol properties. Defaults to `false`.
0 commit comments