Problem List|10. Deep Clone JavaScript ObjectMedium

10. Deep Clone JavaScript Object

JavaScript CoreDOM & Browser
Implement a `deepClone(obj)` function that returns a deep copy of an arbitrary nested JavaScript object or array. Mutating the cloned object must not affect the original object. The function must handle primitives, objects, and nested arrays.
Example 1:
Input: obj = {"a": 1, "b": {"c": 2}}
Output: {"a":1,"b":{"c":2}}
Explanation: Deep copy created with independent nested references.

Constraints:

  • Objects contain JSON-serializable primitives and nested structures.
Integrity: 100%
Loading...
Input Arguments:
obj = {"a": 1, "b": {"c": 2}}
Expected Output:
{"a":1,"b":{"c":2}}