Have any difference var name; name = 1; vs var name = 1;

Have any difference var name; name = 1; vs var name = 1;
0.0 0

#1

So there can set values like

var number = 1;

var number;

number = 1;

Have any difference in usage where need to set first and second to work the code?


#2

It really just depends on context. Sometimes you will want a variable to have an initial value. Sometimes Bad Things can happen if a variable is undefined. It’s just a matter of how that variable will be used in the rest of the function.


#3

Still you know something about var names need to set before function or after?


#4

What? Are you trying to ask about global vs local scope?