9 Declare Javascript Variable – JavaScript for Beginners

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

9 How to Declare Javascript Variable - JS 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.

How do you declare variables.

To declare variables, you have different ways you can do it.

In JavaScript, you can declare variables using the ‘var’ keyword.

You can also declare variables without using any keyword.

And, you can declare using the ‘let’ keyword.

So you can say ‘var x’ is equals to whatever.

In this case, this has been instantiated.

But I will come to that later on.

In this case, there is no keyword here.

So this gives, this gives rise to what you call a global variable.

So if you declare a variable without using any keyword, in this case it will give you a global variable that can be accessed out of the scope of where this.

You’ll see this in future and understand it better.

And then we have the ‘let’.

Now this is new in ECMAScript 2015.

So that means it’s not supported in some browsers as of now, but implementations are ongoing.

So in future versions of web browsers, most of these features will be supported that are new in ES6.

And as I said earlier on in one of the earlier videos, I am using the MDN JavaScript documentation which is written based on the latest draft of JavaScript which is ECMAScript 2017.

So there are certain features that we are going to encounter from ECMAScript 2015, as well as from ECMAScript 2017.

And the good thing about the MDN documentation is that they are labeled.

So when we get there, I’ll look at them and see what they say about each of the ones that are marked and I will communicate the same to you.

Okay, so we have variables declared using the ‘var’ keyword, without any keyword and the ‘let’ keyword.

So the difference between this and this is in scoping.

So we’ll talk about variable scopes.

Basically scope means where it has effect.

Within which block does that particular variable has effect.

So that his scope.

And we’ll look at variable scopes later on.

So I don’t like to make really long videos.

So I’m going to end this video here and then in the next video, I’m going to talk about variable instantiation and also about variable declaration.

So you’ll declare and instantiate.

In this case, I declared the variable and I did instantiate it at the same time.

So in the next video, let’s look at how you can do without instantiating the variable.

See you then.

This section is from Learn Javascript from Scratch.

Learn Javascript from Scratch

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!