22 Javascript const the real demo for block level

Last updated on July 13th, 2020 at 02:17 pm.

22 Javascript const the demo for block level - JavaScript Tutorial 2018

This video is taken from the full course that will teach you HTML, CSS, Programming concepts and Javascript .

Video Transcript:

Hi, and welcome back.

So you’ve seen that I’ve been naming my constants with capital letters.

Well you can use small letters or capital letters.

But in most programming languages, you’ll find that most constants, they’re always defined with a capital letter.

So I’m just trying to do the same thing.

Just following those conventions.

I suggest you use capital letters.

At least it will help you know just by looking at your own code, that that is a constant.

So in the last video, I said that we’re going to see and do some experiments just to see what happens if I copy this and I just do that.

So first let me remove this and then of course remove this, remove this.

Now we have ‘const VAT’ defined here and here.

I want it to be ‘160’.

So you can see these are two different blocks.

So if I say ‘alert(VAT);’, so that it can show us the value of the ‘VAT’ which is here and the value of the ‘VAT’ which is here.

So I’ll just copy the same thing and put it here.

So this statement will run.

The ‘if’ statement will run because this statement is true.

That’s why I used ‘true’.

You know what, I can just do another copy as well.

And copy there and let’s make this one ‘1600’.

I’m just using this as an example.

So, if I run this, I should be able to see if it is going to give us all these examples, all these values of ‘VAT’.

Because this is a different block, that’s a different block and that’s another block.

So if I run this and I come here, you see the first one is ‘16’.

If I click okay, the second one of ‘160’ is also there, then 1600 is also there.

So what that shows us is that this is a block level thing.

You can see I can declare a constant in one block and redeclare the same constant in another block with a different value and there won’t be any issues.

So that’s exactly what block level means.

So in this video, we’ve seen that ‘const’ is truly a block level variable.

We declared it in one block and then redeclared it in another block and yet in another block, with different values and all the values were brought back with the actual values within those specific blocks.

So in the next video, let’s look at something else, if there’ll be anything else about constants.

So I will see you in the next video.

Comment Here

Need WordPress help? Linux Server help? Talk to us.

  • We are your own WordPress customer service.
  • We set up Linux servers and install or migrate WordPress. Learn more here.
  • We support WooCommerce too.
  • Check out our WordPress customer support plans here or contact us below .

If you have any questions regarding WordPress support, Linux server support or any of our services, feel free to reach out or read more on our services page.

Join this free course:

How to host multiple WordPress
websites on a VPS

Close me!