The final kind of scope in JavaScript is block scope. So block scope is achieved by using the let, or const keywords inside of a block. Now, it was introduced in the ECMO script 2015 version of JavaScript. So before ECMO script 2015, we had two kinds of scope, global and private. And then after echo script 2015 was rolled out. We have three kinds of scope, global, private, and block level scope.
So you may be asking yourself, what is a block? Well, this is a black block is opening and closing curly braces. And inside of those curly braces, you put your code any code you put inside of those curly braces is block level code. So for example, I have this variable I and I declared it by using the link keyword, bow. So by using the let keyword inside of a block, I becomes scoped to that Block. Now I could also have another IV variable that's defined in this case globally, because once again, if any code that's not defined in a function is defined globally, so here I've got this global variable called I, and then I've got this other variable called is equal to 50 inside of the block, and these two can coexist very happily because the first one is globally scoped.
And the second one is block scoped. So I could also use the const keyword to create that second I variable, the differences. If I use the let keyword, I could turn around overwrite that variable, the next line of code, I could say, let i equal 50. And then I could say, let i equal 5000. No problem. But when I use the const keyword, that's a constant.
So once I do that, I cannot try to change I i is i. So if I say const i equals 50, and then say const i equals 5000. I'll get an error because I can't overwrite it. So the difference between let const is they both create block level variables or block scope. But const when you use that keyword, you cannot override it. So once again, there's three different ways now to create a variable there is var which creates private scope.
There's let which creates a block level are a block scoped variable. And there's the const keyword which also creates a block scoped variable, but that value assignment cannot be changed.