| 1 |
class C { |
| 2 |
static testIf(o) { |
| 3 |
if (o?.a.b.c.d) { |
| 4 |
return true; |
| 5 |
} |
| 6 |
return false; |
| 7 |
} |
| 8 |
static testConditional(o) { |
| 9 |
return o?.a.b?.c.d ? true : false; |
| 10 |
} |
| 11 |
static testLoop(o) { |
| 12 |
while (o?.a.b.c.d) { |
| 13 |
for (; o?.a.b.c?.d; ) { |
| 14 |
let i = 0; |
| 15 |
do { |
| 16 |
i++; |
| 17 |
if (i === 2) { |
| 18 |
return true; |
| 19 |
} |
| 20 |
} while (o?.a.b?.c.d); |
| 21 |
} |
| 22 |
} |
| 23 |
return false; |
| 24 |
} |
| 25 |
static testNegate(o) { |
| 26 |
return !!o?.a.b?.c.d; |
| 27 |
} |
| 28 |
static testIfDeep(o) { |
| 29 |
if (o.obj?.a.b?.c.d) { |
| 30 |
return true; |
| 31 |
} |
| 32 |
return false; |
| 33 |
} |
| 34 |
static testConditionalDeep(o) { |
| 35 |
return o.obj?.a.b?.c.d ? true : false; |
| 36 |
} |
| 37 |
static testLoopDeep(o) { |
| 38 |
while (o.obj?.a.b.c.d) { |
| 39 |
for (; o.obj?.a.b.c?.d; ) { |
| 40 |
let i = 0; |
| 41 |
do { |
| 42 |
i++; |
| 43 |
if (i === 2) { |
| 44 |
return true; |
| 45 |
} |
| 46 |
} while (o.obj?.a.b?.c.d); |
| 47 |
} |
| 48 |
} |
| 49 |
return false; |
| 50 |
} |
| 51 |
static testNegateDeep(o) { |
| 52 |
return !!o.obj?.a.b?.c.d; |
| 53 |
} |
| 54 |
|
| 55 |
static testLogicalInIf(o) { |
| 56 |
if (o?.a.b?.c.d && o?.a?.b.c.d) { |
| 57 |
return true; |
| 58 |
} |
| 59 |
return false; |
| 60 |
} |
| 61 |
|
| 62 |
static testLogicalInReturn(o) { |
| 63 |
return o?.a.b?.c.d && o?.a?.b.c.d; |
| 64 |
} |
| 65 |
|
| 66 |
static testNullishCoalescing(o) { |
| 67 |
if (o?.a.b?.c.non_existent ?? o?.a.b?.c.d) { |
| 68 |
return o?.a.b?.c.non_existent ?? o?.a.b?.c.d; |
| 69 |
} |
| 70 |
return o?.a.b?.c.non_existent ?? o; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
C.test(); |
| 75 |
C.testNullish(); |