JavaScript utilities · Senior · about 25 minutes
Deep clone
Implement deepClone(value) without structuredClone or JSON (the tests remove both). Copy plain objects, arrays, Date, Map and Set at every depth. Keep functions and primitives as they are. Handle cycles: an object that points to itself must clone to an object that points to the clone. Each test builds a value, clones it, and reports checks that must all be true.
Start from
function deepClone(value) {
// Return a deep copy that shares nothing mutable with the input.
}Hints and solution
Solve it in the app: its tests run without a year.
The hints, the solution and what an interviewer looks for opens with a year in the app. What a year includes