Var names with undefinied

Var names with undefinied
0.0 0


What is that situation when only need set a
var thisone; // this means undefined
in some codes see that is have used. What ways need to be set var like this? I think because if you set var thisone = 1; not will work.


they are both valid ways of defining and initializing a variable.
Define with
var thisone;
Define and initialize with
var thisone = 1;

Both are valid and have their own uses.


And what about

var thisone;

and init with thisone = 1;

I saw this one in a count script. So this works with count or something?


yes, of course another usage is
var thisone;
thisone = “anything I want!”;

The second line initializes the value of thisone to whatever you want.
There are a million ways to use these variables and these initializations.

Keep coding and you will learn more…


I see on many sites. Copy paste js code and know nothing about it. Just try to understand what i am doing.


sure thing. I’m sorry if my explanation is not helping.
If you wish you can also google your question and find lots of resources on javascript variables and their usage.


var thisone; creates new variable called thisone that can hold some value be it a integer floating point number, string object, or boolean. All it is space to hold something. Until you give it something hold the value is undefined. When you use the = sign to to assign it to something be it a number, string object or another variable then it holds that value. Also your variable thisone should be named “thisOne”. If you don’t know what thisone will hold the write " var thisone;" if you know what thisone should hold (you can change it later) write “var thisone= somthing;”