Skip to content

Commit 6cd9550

Browse files
deepClone tutorial
1 parent ad41072 commit 6cd9550

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function deepCloneWithKeyRemoved(obj, keyname){
2+
let deepClone = JSON.parse(JSON.stringify(obj))
3+
delete deepClone[keyname]
4+
return deepClone
5+
}
6+
7+
var obj = { a: 7, b: 2, c: {value:3} };
8+
console.log(
9+
'inputs :',obj
10+
)
11+
console.log(
12+
'outputs:',deepCloneWithKeyRemoved(obj, 'a')
13+
)
14+

0 commit comments

Comments
 (0)