Skip to content

Commit ccbe80d

Browse files
authored
Create util.js
1 parent 1f59376 commit ccbe80d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

util.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var srcObj = {
2+
a: 1,
3+
b: {
4+
b1: ["hello", "hi"],
5+
b2: "JavaScript"
6+
}
7+
};
8+
var abObj = srcObj;
9+
var tarObj = cloneObject(srcObj);
10+
11+
srcObj.a = 2;
12+
srcObj.b.b1[0] = "Hello";
13+
14+
console.log(abObj.a);
15+
console.log(abObj.b.b1[0]);
16+
17+
console.log(tarObj.a); // 1
18+
console.log(tarObj.b.b1[0]); // "hello"

0 commit comments

Comments
 (0)