Clone Deep
Deep clone an object. A deep clone is a clone of the source object and all of its children, and their children, and so on.
Category | Objects |
Author | Pol Gubau |
Since | 1.0.0 |
Last Updated | 2025-03-15 |
Type | Sync |
Compatibility | Universal |
Example
Input
cloneDeep({ a: { b: 1 } })
Output:
{ a: { b: 1 } }
Return
Returns a deep clone of the source object.
Type: T
Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
source | T | null | Yes | The source object to clone. |
Notes
The function recursively clones the object and its nested properties. If the source is not an object, it is returned as is.
Tags
- clone
- deep
- object
- recursion
Related
- arrays
- universal
- sync
- Since 1.0.0
- validations
- universal
- sync
- Since 1.0.0
- objects
- universal
- sync
- Since 1.0.0
groupBy
Groups the elements of an array based on a provided key-generating function.
isObject
Checks if the provided parameter is a plain object.
getMainField
Retrieves the main field from an item object based on a predefined list of labels to highlight.