10 Variables example – JavaScript for Beginners

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

10 JS Variables example - JavaScript Tutorial 2018

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

Video Transcript:


Welcome back.

So let’s go to the browser and see all of this in action.

So I’ll go to Firefox.

Now, I will be using Firefox.

If you don’t have Firefox installed, go to ‘mozilla.org’ and install Firefox.

And the reason I will be using Firefox is because I want to use Scratchpad.

And to open Scratchpad on Firefox, you’ll just press Shift+F4 on your keyboard.

And this is what I’ll be using for some experimentations of the code and some demonstrations.

So the first thing I want to do here, I’ll just remove this.

If you look at this documentation, you can see, even in Mozilla they use things like console.log to show examples.

But I just want to use, I want to use ‘alert’.

So in my case, I will be using ‘alert’ to show examples.

So once I just say ‘alert’ and I click on run, it will show me the alert here.

So that’s why I want to use it.

I can just do things and test them immediately and if there are any errors, it will also let me know using comments right here on Scratchpad.

So if you want to use Scratchpad as well, you can download Firefox and follow along with me.


So, let’s say we declare a variable.

So you can declare a variable using the ‘var’ keyword.

So var a; So we’ve declared a variable var a; and we haven’t instantiated the variable ‘a’.

So how it works is this.

First of all, you declare the variable, so that the system can know that there is a variable called ‘a’.

And then you give that variable a value.

So in this case I can say, ‘var a’, then I can put it in a different line and say ‘a=4’.

And then, now if I do an alert, ‘alert(a)’, we know that ‘a’ has a value of 4.

So if I alert this, if I run this, it’ll give us the value of 4.

Let me close that one.

So if I run this, it give us that value of 4.


You declare the variable and then you give it an instance.

So in this case, I declare the variable and give it an instance in the same line.

So I can also do the same thing right here.

So if I come here and delete this line and I give this the instance of 4, I give it that value of 4 and then I run it, it’ll give us the same 4.

If I change the value, maybe 1000, then I run, it’ll change the value.

So let’s continue from here in the next video.

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!