Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,16 @@ The `catch` block receives the argument `x`. This is not the same `x` as the var
Later, we set this block-scoped variable equal to `1`, and set the value of the variable `y`. Now, we log the block-scoped variable `x`, which is equal to `1`.

Outside of the `catch` block, `x` is still `undefined`, and `y` is `2`. When we want to `console.log(x)` outside of the `catch` block, it returns `undefined`, and `y` returns `2`.
<pre>
let x; // Outer x
try {
throw new Error();
} catch (x) { // Inner x, shadows outer x
x = 1; // Inner x is set to 1
// The outer x is still undefined
}
</pre>


</p>
</details>
Expand Down