-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
main.js
47 lines (36 loc) · 825 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
let x1 = false;
modifyX1();
const obj1 = { modified: false };
x1 ? obj1 : {};
if (obj1.modified) console.log('should not happen');
else console.log('not modified');
function modifyX1() {
x1 = true;
}
let x2 = false;
modifyX2();
const obj2 = { modified: false };
(x2 ? obj2 : {}).modified = true;
if (obj2.modified) console.log('modified');
else console.log('not modified');
function modifyX2() {
x2 = true;
}
let x3 = false;
modifyX3();
const obj3 = { modified: false };
x3 && obj3;
if (obj3.modified) console.log('should not happen');
else console.log('not modified');
function modifyX3() {
x3 = true;
}
let x4 = false;
modifyX4();
const obj4 = { modified: false };
(x4 && obj4).modified = true;
if (obj4.modified) console.log('modified');
else console.log('not modified');
function modifyX4() {
x4 = true;
}