Last active
August 28, 2021 15:43
-
-
Save tararoutray/990247a542425d8efde7d4513c046d29 to your computer and use it in GitHub Desktop.
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
// Let's declare a variable named "emailAddress" | |
let emailAddress = '[email protected]'; | |
// If accidentally we redeclare anathor variable with the same name, | |
// then the compiler will throw an error, which is indeed a great practice. | |
let emailAddress = 'abc'; | |
// Uncaught SyntaxError: Identifier 'emailAddress' has already been declared | |
// Now let's declare a variable within a loop | |
for(let i = 0; i < 10; i++) { | |
// Variable "i" can be accessible within this loop | |
console.log(i); | |
} | |
// Now let's print this "i" outside the "for" loop | |
console.log(i); | |
// The compiler or web browser will throw an error if you try to print the value of "i" outside the "for" loop: | |
// Uncaught ReferenceError: i is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment