Write a function deepClone(obj) that returns a deep copy of a given nested object or array containing primitive values. For example, modifying a nested property in the clone returned by deepClone({ a: 1, b: { c: 2 } }) must not modify the original object.
function deepClone(obj) {
// Your code here
}
Rules:
- Must handle nested objects and arrays of arbitrary depth.
- Must properly preserve primitive data types (numbers, strings, booleans, null).
- Do not use structuredClone() or JSON.parse(JSON.stringify()).
Post your solution as a reply. Answer goes up in about a day.