Created
June 9, 2020 06:43
-
-
Save arunrreddy/86d4020833059ddf07acb74022c64df6 to your computer and use it in GitHub Desktop.
BJS Intro - Scoping in JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function myFunction() { | |
| var a = 10; | |
| if (a === 10) { | |
| var a = 30; | |
| let b = 20; | |
| } else { | |
| let c = 30; | |
| } | |
| console.log(a); | |
| console.log(b); | |
| console.log(c); | |
| } | |
| myFunction(); | |
| // 30 | |
| // Uncaught ReferenceError: b is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment