Let me try to explain this a different way for you.
The computer has a memory. The memory is for remembering data.
An example of data that the computer can remember is numbers.
Now try to imagine the memory of the computer like drawers.
Each drawer can hold one thing.
To keep track of which drawer has what, the drawers have names. We can these names “variables”. So a variable is actually the name of part of the computer’s memory.
In this case the language requires that we use a certain ‘vocabulary’ and ‘grammar’. The vocabulary of a language is things like ‘var’ which is a special key that is understood to mean ‘variable’.
The grammer of the language is what we refer to as syntax.
Syntax tells us the order we write things in so they make sense to the computer.
So if I said:
It will know that I want to store something in memory and that I want to call that area of memory ‘a’.
But if I write
That is the wrong syntax and it will not understand it the way I want it to.
a = 7;
What these two are doing is that they are telling the computer to store a number 7 inside a variable called ‘a’.
We “declared” the variable first. This is an important step. To ‘declare’ is like an announcement. We are announcing to the computer that we want to store something in memory (in a variable called a)
Then we did an “assignment”.
a = 7;
a = 7;
this will store the number 7 in memory in a location called a
So always the variable on the left hand-side of the equal is the memory location we are storing things in. (so try to remember that if it is on the left, it is the location we are keeping things in - in memory)…
this one declares another place in memory (which is at the moment not having anything interesting in it - yet).
We want to tell the computer to copy the contents of the memory location we call a and put it inside of b.
Remember the rules.
The variable on the left is the location of memory where things will be placed (or another way to say this, the variable on the left is getting assigned something).
So how would you tell the computer to take the content of a and put it inside of b?