In this video.
Let's talk about block scope.
So let me comment.
This one's.
Copy this one down here.
I'm going to be as block scope in JavaScript.
BLOCK scope refers to the visibility of variables within a code block, and the code block is a set
of carry braces that encloses one or more statements.
So let's see.
So let's declare a variable.
Let's.
H equal to 30.
And now let's use if statement to create code block and here we go if and then my code block so whatever
I declare inside the code block, it becomes what my block scope let's see.
So let's say that if the age above because this in a global scope I can access it here.
So if.
So if H is.
More than 18 years and we can say that you are old enough.
So let's also declare a variable core message which is equal to you.
Are old enough.
Great.
And now we can console.log the message.
And that, so let's save it.
And now indeed you are old enough, but here is a clue.
Remember that we have declared a variable called age in a global scope and line number 31.
We also declare a variable called message inside a code block.
So now this variable is in a block scope.
I cannot access this outside my block scope.
Let's see if I try to console that, log the message inside my code block.
Let's see I get an error.
This means that this message is in scope to this code block here, but if I try to access it, I can
still access it because it is in a global scope.