-
Notifications
You must be signed in to change notification settings - Fork 0
Library: clone()
Eugene Lazutkin edited this page Jul 3, 2018
·
1 revision
clone() module is a function, which creates a functional replicate of an object. It handles correctly Date, RegExp, Array objects as well as Object-based and null-based objects and primitives. It supports sparse arrays and non-standard properties on array objects.
In a module-enabled environment (like Babel) it can be accessed like that:
import clone from '@researchnow/reno/src/utils/clone';In global-based environments (like a browser) it is frequently mapped to Reno.utils.clone.
The function takes the following arguments:
-
objectis a valid JavaScript value to be cloned.
It returns a newly cloned value.
const initial = {_id: 1, value: 'x', next: {_id: 2, value: 'y', next: null}};
const result = clone(initial);
assert(isEqual(initial, result));