2. Deep copy - rolling-scopes-school/RS-Short-Track GitHub Wiki
Folder Name | Branch | Coefficient |
---|---|---|
deep-copy | deep-copy | 0.3 |
Your task is to implement the function copy
that creates a copy of an object.
- Usage of rest/spread operator is strictly forbidden
- Your implementation should implement a 'deep' copy if some property is an object you should also copy it. (Pay attention to arrays)
- Usage of any npm lib will result to -100%pts
- Usage of
structuredClone
is strictly forbidden - Usage of
JSON.stringify
,JSON.parse
is forbidden
Example:
const obj = {
a: 4,
b: {
c: 5,
},
};
const obj1 = copy(obj)
//obj1 is a newly created object
obj1 === obj // false;
obj1.b === obj.b // false;