Interview practice question
Implementing a deep clone that handles edge cases
Frontend Engineering · JavaScript Core · Experienced
You can't use structuredClone because you need to preserve class instances. How would you implement a deep clone?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Handle primitives, null.
- Track visited objects (WeakMap) for cycles.
- Preserve prototype (Object.create(getPrototypeOf)).
- Special types: Date, Map, Set, RegExp.
- Copy property descriptors/symbols if needed.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.