Skip to content

Commit 2de633c

Browse files
committed
doc: update example of using await in REPL
Lexical scope of `const` is only invalidated when using top-level `await` in REPL. Fixes: #45918
1 parent 0f4446c commit 2de633c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

doc/api/repl.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,20 @@ undefined
234234
undefined
235235
```
236236

237+
One known limitation of using the `await` keyword in the REPL is that
238+
it will invalidate the lexical scoping of the `const` keywords.
239+
240+
For example:
241+
242+
```console
243+
> const m = await Promise.resolve(123)
244+
undefined
245+
> m
246+
123
247+
> m = await Promise.resolve(234)
248+
234
249+
```
250+
237251
[`--no-experimental-repl-await`][] shall disable top-level await in REPL.
238252

239253
### Reverse-i-search

0 commit comments

Comments
 (0)