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.

CategoryObjects
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

Example

  • Input

    cloneDeep({ a: { b: 1 } })

    Output:

    { a: { b: 1 } }

Return

Returns a deep clone of the source object.

Type: T

Props

NameTypeDefaultRequiredDescription
sourceTnullYesThe 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