cloneDeepWith<T>(obj: T,cloneValue: () => any,): T
Deeply clones the given object.
You can customize the deep cloning process using the cloneValue
function.
The function takes the current value value
, the property name key
, and the entire object obj
as arguments.
If the function returns a value, that value is used;
if it returns undefined
, the default cloning method is used.
Example 1
Example 1
// Clone a primitive value const num = 29; const clonedNum = cloneDeepWith(num); console.log(clonedNum); // 29 console.log(clonedNum === num); // true
- A deep clone of the given object.