Objects & Recursion

Deep Clone Object

mediumJS SpecificJS / TS7 tests

Problem Statement

Write a function `deepClone(obj)` that returns a deep copy of an object or array, handling primitives, nested objects, arrays, and dates without using `structuredClone` or `JSON.parse(JSON.stringify(obj))`.

Examples

Example:
const original = { a: 1, b: { c: 2 } };
const copy = deepClone(original);
copy.b.c = 42;
console.log(original.b.c); // 2
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

7 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.