소바·2022년 8월 3일

Why it's called a var?

Why it's called a var, is because it stands for the word variable. So that means you can vary the data that you keep inside it.

so whenever the computer encounters the keyword var it essentially knows that it has to construct a new container.

and this contaniner gets given a name whatever it is that we put after the word var, and in this case we call it myName.

Now after the equal sign is what we're going to place inside the box and in this case it's the string that's ‘Angela’.

As I mension of why it's called a var, if I wanted to change it, then I can tap into that same container, by writing its name and I can set it equal a new value.

It’ll take out the content(Angela) that's currently contained and delete it, and then it will reassign it a new value(Jane) depending on what I wrote on the right hand side of the equal sign.

I varied what's contained inside my box.

Should I repeat a var when decide to change?

We don't have to repeat the keyword var again.

The word var is only used when you're constructing a new box.

So you don't need to use, when you decide to use the variable or when you decide to change the variable that keyword var anymore.


0개의 댓글