Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started

lodash.clonedeep 4.0.0

The lodash method `_.cloneDeep` exported as a module.
Package summary
Share
0
issues
0
licenses
Package created
23 Sep 2013
Version published
13 Jan 2016
Maintainers
2
Total deps
0
Direct deps
0
License
MIT
Error Generating Report

Frequently Asked Questions

What does lodash.clonedeep do?

The "lodash.clonedeep" is a handy npm package that provides functionality of the "_.cloneDeep" method from lodash library. It allows you to create deep copies of JavaScript objects. These copies won't be tied to the original objects, meaning changes to copies won't affect the original ones and vice versa. It's especially relevant in contexts where immutability is crucial, for example, while working with Redux in React or while manipulating complex nested objects where a shallow copy would not be enough.

How do you use lodash.clonedeep?

To use the "lodash.clonedeep" function in your JavaScript project, you first need to install it through npm. Run the following command in your terminal:

$ npm i --save lodash.clonedeep

Once installed, you can then require the package in your JavaScript file like this:

var cloneDeep = require('lodash.clonedeep');

Afterwards, you can use the "cloneDeep" function to create deep copies of your objects:

var object = { a: 1, b: 2 };
var deepCopy = cloneDeep(object);

console.log(object === deepCopy); // Output: false

deepCopy.a = 5;
console.log(object.a); // Output: 1
console.log(deepCopy.a); // Output: 5

The example above shows that a change to the copy (deepCopy.a) does not affect the original object (object.a).

Where are the lodash.clonedeep docs?

The comprehensive documentation including the details about the usage of "lodash.clonedeep" module can be found on the lodash's official website. The specific section for "cloneDeep" method is available at this URL: https://lodash.com/docs#cloneDeep. Besides, you can also explore the package source for more details on GitHub via this link: https://github.com/lodash/lodash/blob/4.5.0-npm-packages/lodash.clonedeep.