react-usekit

Beta

deepClone

Create a deep copy of objects and arrays, handling nested structures safely.

Installation

npx react-usekit@latest init

Select: utils → TypeScript or JavaScript → path -> deepClone

Usage

import { deepClone } from "./utils/deepClone";

function App() {
  const original = { name: "John", hobbies: ["reading", "coding"] };
  const cloned = deepClone(original);

  return (
    <div>
      <p>Original: {JSON.stringify(original)}</p>
      <p>Cloned: {JSON.stringify(cloned)}</p>
    </div>
  );
}

API

Parameters

ParameterTypeDescription
objTThe object or array to clone

Returns

TypeDescription
TA deep copy of the input object