/
main.js
49 lines (45 loc) · 871 Bytes
/
main.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const obj1 = {
noMutation() {},
prop: true
};
obj1.noMutation();
if (obj1.prop) console.log('retained');
else console.log('removed');
const obj2 = {
noMutationEffect() {
console.log('effect');
},
prop: true
};
obj2.noMutationEffect();
if (obj2.prop) console.log('retained');
else console.log('removed');
const obj3 = {
mutateProp() {
this.prop = false;
},
prop: true
};
obj3.mutateProp();
if (obj3.prop) console.log('unimportant');
else console.log('retained');
const obj4 = {
mutateUnknownProp() {
this[globalThis.unknown] = false;
},
prop: true
};
obj4.mutateUnknownProp();
if (obj4.prop) console.log('retained');
else console.log('retained');
const obj5 = {
mutateNestedProp() {
this.nested.prop = false;
},
nested: {
prop: true
}
};
obj5.mutateNestedProp();
if (obj5.nested.prop) console.log('unimportant');
else console.log('retained');