-
Notifications
You must be signed in to change notification settings - Fork 3
/
playground_03.js
42 lines (33 loc) · 1.18 KB
/
playground_03.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
/* eslint-disable */
// --------------
// Extra material
// --------------
// !--------------------------------------------------
// ! Logical operators in JavaScript
// !--------------------------------------------------
// ! Deep dive into &&, || and ??
// ! ----------------------------
const myBool = true;
const conditionalObject = myBool && {
a: 1,
b: 2,
};
const what = {
...conditionalObject,
};
console.log(typeof conditionalObject);
// ? 🐆 [Task]:
// ? 1. Switch the `myBool` value from true to false and observe the
// ? result of the console.log statement
// ? 2. In `conditionalObject`, change the logical AND operator `&&`
// ? to the logical OR operator `||` and then to nullish coalescing operator `??`
// ? 🐒 [Question]: Which results do you observe? Can you explain them?
// Your answer:
//
//
//
// Links
// -----
// &&: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND
// ||: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR
// ??: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator