Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.clone

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.clone

The lodash method `_.clone` exported as a module.

  • 4.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
461K
decreased by-43.55%
Maintainers
3
Weekly downloads
 
Created

What is lodash.clone?

The lodash.clone package is a utility library that provides a method to create shallow copies of values. It is part of the larger Lodash library, which is known for its wide range of utility functions for common programming tasks.

What are lodash.clone's main functionalities?

Shallow Clone of Objects

This feature allows you to create a shallow copy of an object. The cloned object will have the same properties as the original object, but changes to the cloned object will not affect the original object.

const _ = require('lodash.clone');
const obj = { a: 1, b: 2 };
const clonedObj = _.clone(obj);
console.log(clonedObj); // { a: 1, b: 2 }

Shallow Clone of Arrays

This feature allows you to create a shallow copy of an array. The cloned array will have the same elements as the original array, but changes to the cloned array will not affect the original array.

const _ = require('lodash.clone');
const arr = [1, 2, 3];
const clonedArr = _.clone(arr);
console.log(clonedArr); // [1, 2, 3]

Shallow Clone of Nested Objects

This feature allows you to create a shallow copy of a nested object. Note that only the first level of the object is cloned; nested objects are still referenced.

const _ = require('lodash.clone');
const nestedObj = { a: { b: 2 } };
const clonedNestedObj = _.clone(nestedObj);
console.log(clonedNestedObj); // { a: { b: 2 } }
clonedNestedObj.a.b = 3;
console.log(nestedObj.a.b); // 3

Other packages similar to lodash.clone

Keywords

FAQs

Package last updated on 30 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc