One of the most important concepts to understand in JavaScript is the scope. **What is Scope?** The scope of a variable controls where that variable can be accessed from. We can have a global scope meaning that the variable can be accessed from anywhere in our code or we can have a block scope meaning that the variable can be accessed only from inside of the block where it has been declared.” A block can be a function, a loop or anything delimited by _curly brackets_. Let's have a look at two examples, first using the keyword var. ```js var myInt = 1; if(myInt === 1) { var mySecondInt = 2 console.log(mySecondInt); // 2 } console.log(mySecondInt); ``` } As you can see we were able to access the value of mySecondInt event outside of the block scope as variables declared with the keyword var are not bound to it. Now let's use the keyword let. ```js var myInt = 1; if(myInt === 1) { let mySecondInt = 2 console.log(mySecondInt); // 2 } console.log(mySecondInt); // Uncaught ReferenceError: mySeconfInt is not defined ``` This time we couldn't access the variable from outside of the block scope and we got an error mySecondInt is not defined. Variable declared with the keywords let or const are bound to the block scope where they have been declared.
this implementation was done in **ES6** and brought a lot of improvements to the handling of the code