Skip to main content

cloneDeep

Callable

  • cloneDeep<Arr>(x: Arr): Arr
  • cloneDeep<T>(x: T): T
  • cloneDeep<V>(x: V): V

  • If the input is an array, map over it and recursively call cloneDeep on each element. If the input is an object, map over its entries and recursively call cloneDeep on each value. Otherwise, return the input.

    Example

    cloneDeep([1, 2, 3])
    // => [1, 2, 3]

    Alternatives

    @deprecated

    Type parameters

    • Arr: unknown[]

    Parameters

    • x: Arr

      The object to clone.

    Returns Arr

    A new object with the same keys and values as the original object.