2025-10-11 17:09
Status:
Tags:
What is a Variable?
In programming, we are working with lot's of data. If you built a social media app, you have to store the pictures you upload, all the comments your friends leave on your posts on instagram, all of this can be referred to as data.
Programming language give us the convienienve of stotoring data inside of neatly organized boxes with labels on them, so that we always know what kind of data we are working with. If you've ever moved from one house to another, at the new house, if everything was labled properly, you can pull out a box and know exactly what is inside before you open it, that is what varaibles do for us.
In Javscript, there are different kinds of varaibles, first we'll look at the most simple. Let's create a varaible, for your name, simply write:
var myName = "Michael";
The word var is called a key word, it's a word that Javascript already understands, whatever word you type after var is what Javascript will name your variable.
Next we have myName, this is the actual name of our variable, you can think of it as the label of our container that we can place data inside of and use for later.
Then we have the equal symbol, which let's Javascript know that you want to place data inside of our variable, and it will put whatever data you give it inside of our variable myName.
Then we can use it in other places of our program like this:
console.log(myName);
Which will spit out Michael, when we run our program.
What if we want to change what we place inside of our variable? No problem, we can do that like this:
myName = "John" // New name!
References
Linked Citations