当前位置:网站首页>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)边栏推荐
- Implementation notes of least square fitting conic in stm32
- Permission design = function permission + Data permission
- Leetcode 513. Find the value in the lower left corner of the tree
- Classic interview questions: mouse drug test and Hamming code
- mysql cluster
- mongodb
- Modelsim simulation FFT core cannot be simulated solution (qsys)
- Anaconda beginner's notes
- Data synchronization
- Why is it best to use equals for integer comparisons
猜你喜欢

FPGA notes -- implementation of FPGA floating point operation

Binary sort tree

What are the red lines of open source that should not be trodden on?

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

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

Vscode shortcut

Preorder and middle order traversal of forest

Redis的安装及启动

制作3D浪漫炫酷相册【附源码】

How product managers control the progress of product development
随机推荐
ASP. Net cache cache usage
Classic interview questions: mouse drug test and Hamming code
Atlas200dk刷机
About the use of hc-12 radio frequency module
Comprehensive introduction to Simulink solver
Case: drawing Matplotlib dynamic graph
经典面试题之老鼠试药与汉明码
C#线程池控制Semaphore
C#另外一个new类的方式Ico?以及App.config的使用
Graduation season | fitting the best self in continuous exploration
Summary of push-pull output and open drain output of STM32 and failure of analog IIC driving mlx90615
Anti shake and throttling
1-9Vmware中网络配置
Preordered clue binary tree
Qt之自定义带游标的QSlider
Things / phenomena / things / things / situations / appearances
QT custom QSlider with cursor
ciscn_2019_en_2
. user. PHP website installation problems caused by INI files
学习识别对话式问答中的后续问题