forked from hellowordwlf/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigui1.html
34 lines (30 loc) · 892 Bytes
/
digui1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>深拷贝--递归回调</title>
<script>
//第一种方法:
function aa(param){
if(Object.prototype.toString.call(param)==='[object Array]'){
var obj=[];
param.forEach(value=>{
obj.push(aa(value))
})
}else if(Object.prototype.toString.call(param) ==='[object Object]'){
var obj={}
for(var key in param){
obj[key]=aa(param[key])
}
}else{
return param
}
return obj;
}
var bb={a:1,c:{d:1},b:1000}
var cc=aa(bb)
</script>
</head>
<body>
</body>
</html>