
Full-Stack React, TypeScript, and Node
By :

In this section, we will learn about JavaScript's scoping rules and some new variable types that help to clarify and improve upon some issues regarding these scope rules. This information is valuable since you will be creating variables constantly throughout your career as a software developer, and it is important to understand under what scope a variable can be accessed and under what circumstances it may be changed.
In most other languages, variable scoping happens within any arbitrary set of brackets or begin end scope statements. However, scope in JavaScript is handled by the body of a function, which means when a variable is declared inside a function body using the var
keyword, that variable is only accessible within that body. Let's take a look at an example of this. Create a new file called functionBody.ts
and add the following code to it:
if (true) { var val1 = 1; } function go...