Scoping in JavaScript: The Basicsby@sambernheim
956 reads
956 reads

Scoping in JavaScript: The Basics

by Sam Bernheim5mMarch 3rd, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The goal is to understand the difference between lexical and block scoping. Lexical scoping allows for the redefining of variables that are lexically scoped. Block scoped variables only exist through the use of a variable variable when declared. In contrast, lexical variables can be redeclared. In the second function, the first function will throw an error that the variable cannot be redoared. This is due to the fact that in this case, the variable variable was created with an even an even though the variable is redoed.
featured image - Scoping in JavaScript: The Basics
Sam Bernheim HackerNoon profile picture
Sam Bernheim

Sam Bernheim

@sambernheim

Software Engineer @ Twitter

Learn More
LEARN MORE ABOUT @SAMBERNHEIM'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Sam Bernheim HackerNoon profile picture
Sam Bernheim@sambernheim
Software Engineer @ Twitter

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite