#JS from Start- variables and declaration(var, let and const)

in #hive-1035902 months ago

JS FROM START.png

Hi all!

As I said last week, the best way to do this kind of tutorial is through video, but I don’t have the right tools to do something of good quality video now. So, if you are a starter wish to follow me on this, it would be great.

I assume you already know some basic Html before thinking of doing anything JavaScript so I won’t be talking much about Html, but you will surely pick something Html in the tutorials as time goes.

Before you continue read this to know my current plan for this progressive JS tutorial.

So, let’s roll!

First, you need to create your index.html file and a file for app.js. then you source/link to external .js file on the Html. Also, if you use VSCode, I suggest that you download a live server extension. This will save the stress of reloading the page every time you save file because it automatically loads up. As shown in the image below.

Screenshot (257).png

You can insert Javascript in your Html file, or you can use the .js extension file if you link it with your Html. For clean work, you should put your JavaScript in a different file.

We will be using chrome console to output our work, and there is a lot with chrome console, but I will not talk about it here. I will dedicate a section for it. Just hop in your chrome browser and press f12 key to open it up.

So, we talk on variables and declaration. The words to define a variable is var, let and const. var has been around for the genesis of JavaScript. But let and const were introduced in ES6, which was the updated version of JavaScript language.

This is primary. When you use var or let, you can reassign the variable but you can’t reassign when you used const.

Variable can only be letters, numbers, _,$ and can’t start with a number else there will get an error.

The images below contain the processes and comments for explanation. They are all progressive and you can open them up with OPEN IMAGE IN NEW TAB if it not clear enough.

Screenshot (258).png

Screenshot (259).png

Screenshot (260).png

Screenshot (261).png

Screenshot (262).png

Screenshot (263).png

That is all you need to understand basically about variables and declaration. If you are a starter and you have questions, kindly use the comment section.

Thank you!

cover image-tykee-03.png