Interview practice question
JSON.stringify fails with a circular structure error
Frontend Engineering · JavaScript Core · Intermediate
JSON.stringify throws "Converting circular structure to JSON." How do you handle it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Object references itself somewhere.
- Identify cycle.
- Serialise only needed fields.
- Replacer function with WeakSet.
- Libraries or structuredClone for copying.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.