From a568dfb7266f6f0a8abbe88a02298519ae3912c6 Mon Sep 17 00:00:00 2001 From: Jay Rathod <42869929+JayRathod341997@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:29:39 +0530 Subject: [PATCH] Update README.md Updated the description for the question 38 for better understanding --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index b203a060..33f3499c 100644 --- a/README.md +++ b/README.md @@ -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`. +
+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
+}	
+
+