In Lodash, we can create a deep clone of a value using the _.cloneDeep()
method.
_.cloneDeep(value);
This method accepts the following parameter value:
value
: This is the value that needs to be cloned.The _.cloneDeep()
method returns a deep clone of a given value. This method returns an empty object if the provided value cannot be cloned.
Let’s look at an example of creating a deep clone of a value using the _.cloneDeep()
method in the code snippet below:
In the HTML tab:
lodash
script.In the JavaScript tab:
value
and initialize it.value
.