当前位置:网站首页>Simple deepclone
Simple deepclone
2022-06-26 00:57:00 【ivanfor666】
function deepclone(target) {
// Handwritten simple version deep clone Original values supported ,function,obj,array
if (typeof target === "object") {
if (target instanceof Array) {
const tempArr = [];
for (let i = 0, len = target.length; i < len; i++) {
tempArr.push(deepclone(target[i]))
}
return tempArr
} else {
const tempObj = {};
for (let item in target) {
tempObj[item] = deepclone(target[item])
}
return tempObj
}
} else {
return target
}
}
// The test case
testObj = {a:1,b:2,c:{d:3,e:[4,56]}};
resultObj = deepclone(testObj)边栏推荐
猜你喜欢

.net使用Access 2010数据库

Atlas200dk刷机

AD20(Altium Designer) PCB 高亮网络

Post ordered clue binary tree

Error 65:access violation at 0x58024400: no 'read' permission

Flink报错:Error: A JNI error has occurred, please check your installation and try again

STL tutorial 5-basic concepts of STL and the use of string and vector

Typescript for Web Learning

Leetcode 513. Find the value in the lower left corner of the tree

Ad20 (Altium designer) PCB highlight network
随机推荐
"Method not allowed", 405 problem analysis and solution
No executorfactory found to execute the application
Web学习之TypeScript
About EF page turning query database
[从零开始学习FPGA编程-44]:视野篇 - 集成电路助力数字化时代高质量发展-1-集成电路芯片主要形态
[TSP problem] solving traveling salesman problem based on Hopfield neural network with matlab code
Spark log analysis
mtb13_ Perform extract_ blend_ Super{candidate (primaryalternate) \u unique (nullable filtering \foreign\index\granulati
Making 3D romantic cool photo album [source code attached]
mongodb
卡通shader
SVN
【图像检测】基于高斯过程和Radon变换实现血管跟踪和直径估计附matlab代码
Why is it best to use equals for integer comparisons
Download and install flume
Penetration tool -burpsuite
The maze of God's perspective in robot vision
WordPress
The development context of Ba Kong Yuan universe industry
mysql cluster