← JavaScript
#10 most askedVery commonMediumReferences & copying

Implement deepClone

🏒 Asked in real interviews
No reports yet. Were you asked this? Be the first to say where.
I was asked this

Write deepClone(value) that copies nested objects and arrays, so changing the copy never affects the original. Plain objects, arrays and primitives are enough.

πŸ§ͺ Practice

Write your solution, then press Run tests. Explain your approach out loud as you go.

JavaScript
function deepClone(value) {
  // your code here
}

Output appears here. Press Run or Ctrl/⌘ + Enter.

Try it first. Struggling for a few minutes is how it sticks.