Skip to content

Commit

Permalink
doc: update example of using await in REPL
Browse files Browse the repository at this point in the history
Lexical scope of `const` is only invalidated when
using top-level `await` in REPL.

Fixes: #45918
  • Loading branch information
deokjinkim committed Dec 23, 2022
1 parent 0f4446c commit 31508ee
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,21 @@ undefined
undefined
```

One known limitation of using the `await` keyword in the REPL is that
it will invalidate the lexical scoping of the `const`
keywords.

For example:

```console
> const m = await Promise.resolve(123)
undefined
> m
123
> m = await Promise.resolve(234)
234
```

[`--no-experimental-repl-await`][] shall disable top-level await in REPL.

### Reverse-i-search
Expand Down

0 comments on commit 31508ee

Please sign in to comment.