Declaring a Variable
Before we can use a Variable, we must declare the variable. We do this by typing the keyword var followed by the variable name.
Initializing a Variable
Once we have declared our variable we can then initialize it with a value by typing the variable name followed by a = symbol (assignment operator – more on this will be covered in future posts) and then the value you wish to store in that variable:
var myVariable1 = 5;
Let’s break that down:
var (declaring the variable) myVariable1 (variable name) = (assignment operator) 5 (value);
We can have multiple variables like so:
var myVariable1 = 5;
var myVariable2 = 3;
var myVariable3 = 2;
This is where my #BreakingJS journey begins and I’m equally excited and scared. So without further ado, blog post number 1 is an introduction to JS for those (including myself), who don’t really know what it’s role is in the development world.
If you are wandering what #BreakingJS is all about, check out the debut post here which explains what it is I’m doing.
One thing before we continue:
In order to learn JS, you should already have knowledge of HTML, and if you have CSS too then that’s great. These three languages are important when developing websites and all work together to make your website look and work correctly. If you don’t have a working knowledge of HTML and CSS, then put JS on hold for now and tick those two languages off first.
Here is my analogy of how the three work together using the human face:
HTML (The Face)
The content and structure of your face (website) and how it is laid out. It creates the position of your eyes, nose and lips (sections within your website that you can create using DIV’s etc).
CSS (The Makeup)
This adds makeup (style) to your face (HTML) structure and generally makes it look pretty (or not), depending on how good you are at applying makeup.
JS programs your face (website) so that you can speak, see + hear (submit forms, display interactive galleries, play games).
I hope this makes sense and you enjoyed my artwork 🙂
How will I Learn JS?
I’ve recently started the Free Code Camp course which has really tested my JS knowledge and made me realise that I don’t know what the hell I am doing, so along with continuing that course, I will be doing my own research online, lot’s of reading and using W3Schools and MDN (Mozilla Developers Network) as my reference points.
The reason I am blogging my learning journey, is mainly for myself, but to also help other fellow JS Newbies in #BreakingJS – and also, Vaidehi Joshi inspired me to do so after doing the same with Computer Science (#BaseCS).
I can’t promise that my posts will be accurate, educational, humorous or even well written, but this is for ME, and if anyone else finds it useful, that’s a bonus in my eyes. Feel free to follow along, offer any advice, scrutinise my thinking if you must, but just let me know your thoughts.
You can find all of my #BreakingJS posts here or you can follow my journey via the hash tag on Twitter or Instagram. Feel free to hashtag your progress.