OK, so now before we start to create our first component, I do want to talk a little bit more about
ESX context.
Like I said before, I told you about import statements.
Right.
So in this section, we're going to look at the main differences between VA let and CONSED.
So basically, let and contest are ESX, JavaScript variables, just like.
But there are differences among them.
So now I'm going to show you a good panel to work where?
So now do you see in my browser, I just go to the code pen dot I o.
Gopin is a nice, nice platform here.
You can try out your code and you can see your output.
So it's fun to play with and you can see what's what.
If you want, you can sign up, but you really don't have to.
So here, it's just a nice interface for us.
For now, we don't need HTML worse, he says, I just need the JavaScript window.
So I can minimize the HTML editor and the CBS editor.
OK, so now we can work on JavaScript editor.
So to see our outputs now, I'm going to open my console from here.
All right, so everything's ready now to write some JavaScript code.
OK, so first of all, let's create an outside block.
Which is going to be a function.
So I'm just going to call that OK, academy for now.
And inside this block, I'm going to create another block, which is going to be a simple if statement.
Now, inside of here, let's declare a new variable in the old way and.
We're going to call it va pie.
And it's going to be a number three, that one for OK.
And call that function as well, OK, academy down here.
And then outside of the if block, let's print this out.
So we can see now that we've got three point one four, right?
So the variable is being declared inside this block, but it's still being read and printed out from
outside of that block here.
OK, so now let's clear our console so we change this to be let instead of VAR.
And if we try to do the same thing, then we get a reference here.
Because the variables pie isn't actually accessible from outside of this block, so by the time that
we're running this line here, the variable doesn't exist anymore.
OK, so let's clear the console again.
So what this means is that.
If we had an other variable up here also called pie and then this one to be to and also let's print
this one out.
So if we run this now, we're getting pie declared up here and then we're declaring a new version of
pie, which is to say, OK, so that's being printed out, as you can see here.
And then outside of this block, we're again printing out.
What we can see is to clear the console.
So what I'm trying to say is what you just saw.
If he was let or contest, then they are block scope's, so they only exist within the closest block
that surrounds them.
And that's the same with CONSED as well.
Now, just to demonstrate this here, let's write CONSED instead of let OK works the same way.
And the main difference between Lett and CONSED is const variables are immutable, and that means that
you can't change them.
So if you're using left, you can change and redefine the value within that let variable, but if it's
CONSED then you can't do that.
OK, so for example, let's go back to this and let's say that down here, we're going to declare the
value of PI to be one.
Then if we run this, then, as you can see, that's fine, that's being redeployed.
But if we change this to be a contest and then try to rerun.
Look at that, you say that we've got an error because you can't change the value of the const.
OK, I think that's.
Pretty clear, hopefully it's helped to clear it up.
If not, go back, play around with it, and I'll see you in the next lecture.