You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How many times will we see _Creating value_ logged?
29
+
Any how many times will we see _Creating value_ logged here?
30
+
31
+
In both cases, we will see it logged only once, because promises are created eagerly.
32
+
33
+
Listening to a promise using `.then()` does not affect nor start that promise.
30
34
31
-
We will see it logged only once, because promises are created eagerly. Listening to a promise using `.then()` does not affect nor start the source promise.
35
+
Once a promise has been created, then you may wait to hear its result one time, fifteen times, or not at all, and the original promise will behave the same.
32
36
33
-
Once a promise has been created, then you may wait to hear its result zero times, one time, or fifteen times, and the original promise will behave the same.
37
+
This may seem like a strange limitation, but it simplifies reasoning about promises as they work similar to _values_.
34
38
35
-
If we have a value in a variable, we feel comfortable knowing that the reading of that variable has no effect on its value.
39
+
### How values work
40
+
41
+
If we store a value in a variable, we feel comfortable knowing that the reading of that variable has absolutely no effect on its value.
36
42
37
43
```js
38
44
constvalue=40+2;
@@ -42,6 +48,8 @@ console.log(value);
42
48
console.log(value);
43
49
```
44
50
45
-
42 will be logged three times, but if removed the logs altogether, the value will remain the same. The act of logging had no effect on the source value. Promises work exactly the same.
51
+
42 will be logged three times, but if removed the logs altogether, the value will remain the same. The act of logging had no effect on the source value.
52
+
53
+
Promises work exactly the same.
46
54
47
-
We can use this to our advantage, by thinking about promises in the same way we think about values.
55
+
We can use this to our advantage, by thinking about promises in the same way we think about values.
0 commit comments