-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-initial.js
60 lines (47 loc) · 1.25 KB
/
1-initial.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
50
51
52
53
54
55
56
57
58
59
60
'use strict';
// Prompt:
// Please describe control flow and async behavior in following code:
let i = 0;
const f1 = async () => {
console.log(i++);
await f1();
};
f1();
// After running last one we get output:
/*
```
1
2
3
...
8876
8877
8878
Exception in PromiseRejectCallback:
/Testing/JavaScript/test.js:7
}
^
RangeError: Maximum call stack size exceeded
Exception in PromiseRejectCallback:
/Testing/JavaScript/test.js:6
await f1();
^
RangeError: Maximum call stack size exceeded
node:internal/util/inspect:1585
if (ObjectIs(number, -0)) {
^
RangeError: Maximum call stack size exceeded
at is (<anonymous>)
at formatNumber (node:internal/util/inspect:1585:9)
at formatPrimitive (node:internal/util/inspect:1643:12)
at formatValue (node:internal/util/inspect:770:12)
at inspect (node:internal/util/inspect:364:10)
at formatWithOptionsInternal (node:internal/util/inspect:2279:40)
at formatWithOptions (node:internal/util/inspect:2141:10)
at console.value (node:internal/console/constructor:343:14)
at console.log (node:internal/console/constructor:380:61)
at f1 (/Testing/JavaScript/test.js:4:11)
Node.js v18.20.0
```
*/
// Please propose solution how can we avoid stack overflow in this code.