🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

copyindeep

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copyindeep

对象和数组的深复制/浅复制

latest
npmnpm
Version
1.0.6
Version published
Weekly downloads
4
-69.23%
Maintainers
1
Weekly downloads
 
Created
Source

var clone = require('../copyindeep');
var obj = { b: { c: { d: 1 } } };
var objClone = clone.clone(obj,true);//深复制

var arr = [[1,2],[3,[3,4,5,[6,7]]]];
var arrClone = clone.clone(arr,true);

console.log('------------------------')
console.log('obj clone')
console.log(obj === objClone);//false
objClone.b = 'change';//objClone = {b: 'change'}
console.log(obj,objClone);

console.log('------------------------')
console.log('array clone')
console.log(arr === arrClone);//false
arrClone[0] = 1;//arrClone[0] = 1,arr[0] = [1,2]
console.log(arr,arrClone);

Keywords

clone

FAQs

Package last updated on 22 Jul 2017

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